• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just going to be a manager. Somebody, please take my keyboard.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what is the problem? How does the output differ from your expectation?

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the confirmations. I'll log a bug with Sun --ack! ...with Oracle.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I've since received no update from them.


Things aren't free anymore partner
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic