Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. viewing Java disassembly

viewing Java disassembly

Scheduled Pinned Locked Moved Java
javavisual-studioalgorithmsquestion
7 Posts 4 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mike7411
    wrote on last edited by
    #1

    I am in IntelliJ IDEA. I want to view the disassembly of this code to see if it does two comparisons:

    if (-0.0 == 0.0) System.out.println("they're equal");

    Based on searching, it sounds like IntelliJ can't do that. Anyone know of a Java IDE that can do this? Thank you.

    L J 2 Replies Last reply
    0
    • M mike7411

      I am in IntelliJ IDEA. I want to view the disassembly of this code to see if it does two comparisons:

      if (-0.0 == 0.0) System.out.println("they're equal");

      Based on searching, it sounds like IntelliJ can't do that. Anyone know of a Java IDE that can do this? Thank you.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      At the command prompt in your directory enter the following command:

      javap -c your_program_name

      where "your_program_name" is the name of the class containing the compiled code. If you want more information on the Java development utilities you can find it at Home: Java Platform, Standard Edition (Java SE) 8 Release 8[^].

      J 1 Reply Last reply
      0
      • L Lost User

        At the command prompt in your directory enter the following command:

        javap -c your_program_name

        where "your_program_name" is the name of the class containing the compiled code. If you want more information on the Java development utilities you can find it at Home: Java Platform, Standard Edition (Java SE) 8 Release 8[^].

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        In addition redirecting that to a file is probably going to be a good idea. Even a small class is going to have a lot of output.

        L 1 Reply Last reply
        0
        • M mike7411

          I am in IntelliJ IDEA. I want to view the disassembly of this code to see if it does two comparisons:

          if (-0.0 == 0.0) System.out.println("they're equal");

          Based on searching, it sounds like IntelliJ can't do that. Anyone know of a Java IDE that can do this? Thank you.

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Just curious why/how you expect two comparisons?

          M 1 Reply Last reply
          0
          • J jschell

            Just curious why/how you expect two comparisons?

            M Offline
            M Offline
            mike7411
            wrote on last edited by
            #5

            For doubles, I believe there is a positive zero and a negative zero.

            D 1 Reply Last reply
            0
            • M mike7411

              For doubles, I believe there is a positive zero and a negative zero.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              There is only ever a single comparison made for each comparison operator, so if your code only has a single '==' operator, the JIT'd code will only generate a single IL comparison. -0.0 does occur when a negative floating-point value is so small that is cannot be represented. That does NOT mean it's a different 0 from positive 0.0. You can see this is you try to convert an extremely small value to a string and output it. You can get -0.0. If your code, the compiler will evaluate the comparison and optimize it out, replacing the expression with just 'true'. The resulting code, and what you see in the disassembly, will be very close to:

              if (true) System.out.println("they're equal");

              or, depending on code around this, maybe even:

              System.out.println("they're equal");

              If you want to know how numbers are represented in Java, and most other languages, read The IEEE Standard for Floating-Point Arithmetic (IEEE 754)[^]

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

              1 Reply Last reply
              0
              • J jschell

                In addition redirecting that to a file is probably going to be a good idea. Even a small class is going to have a lot of output.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                True, but even so I doubt it will make a lot of sense to the OP.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups