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. debugger stop button behaving weirdly

debugger stop button behaving weirdly

Scheduled Pinned Locked Moved Java
debuggingjavaquestion
8 Posts 3 Posters 8 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 using IntelliJ IDEA 2023.3.1 (Community Edition), and I'm seeing some weirdness. I made a simple test.

    public class SimpleBreakTest {

    public static void main(String\[\] args) {
        String a = null;
        a.toUpperCase();
    }
    

    }

    I put a breakpoint on the first line: String a = null; Then, I debugged the program, and it stopped at the breakpoint. Then, I pressed the "Stop" button in the debugger. Instead of stopping execution, it looks like it continued because it printed out this message: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because "a" is null at SimpleBreakTest.main(SimpleBreakTest.java:5) Any ideas why the stop button in the debugger doesn't seem to work right? Thanks.

    L J 4 Replies Last reply
    0
    • M mike7411

      I am using IntelliJ IDEA 2023.3.1 (Community Edition), and I'm seeing some weirdness. I made a simple test.

      public class SimpleBreakTest {

      public static void main(String\[\] args) {
          String a = null;
          a.toUpperCase();
      }
      

      }

      I put a breakpoint on the first line: String a = null; Then, I debugged the program, and it stopped at the breakpoint. Then, I pressed the "Stop" button in the debugger. Instead of stopping execution, it looks like it continued because it printed out this message: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because "a" is null at SimpleBreakTest.main(SimpleBreakTest.java:5) Any ideas why the stop button in the debugger doesn't seem to work right? Thanks.

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

      ... because a to upper without an assignment makes no sense anyway.

      "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

      J 1 Reply Last reply
      0
      • M mike7411

        I am using IntelliJ IDEA 2023.3.1 (Community Edition), and I'm seeing some weirdness. I made a simple test.

        public class SimpleBreakTest {

        public static void main(String\[\] args) {
            String a = null;
            a.toUpperCase();
        }
        

        }

        I put a breakpoint on the first line: String a = null; Then, I debugged the program, and it stopped at the breakpoint. Then, I pressed the "Stop" button in the debugger. Instead of stopping execution, it looks like it continued because it printed out this message: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because "a" is null at SimpleBreakTest.main(SimpleBreakTest.java:5) Any ideas why the stop button in the debugger doesn't seem to work right? Thanks.

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

        Are you certain you pressed the stop button?

        1 Reply Last reply
        0
        • L Lost User

          ... because a to upper without an assignment makes no sense anyway.

          "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

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

          Well that is true specifically but in general it isn't relevant. The code is a valid statement. If it was a different method it might do something. And there is no way the debugger should be figuring that out.

          L 1 Reply Last reply
          0
          • M mike7411

            I am using IntelliJ IDEA 2023.3.1 (Community Edition), and I'm seeing some weirdness. I made a simple test.

            public class SimpleBreakTest {

            public static void main(String\[\] args) {
                String a = null;
                a.toUpperCase();
            }
            

            }

            I put a breakpoint on the first line: String a = null; Then, I debugged the program, and it stopped at the breakpoint. Then, I pressed the "Stop" button in the debugger. Instead of stopping execution, it looks like it continued because it printed out this message: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because "a" is null at SimpleBreakTest.main(SimpleBreakTest.java:5) Any ideas why the stop button in the debugger doesn't seem to work right? Thanks.

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

            It is of course not really worth figuring it out. And presuming you can replicate it. But if you are just curious and have time... Try adding a few more statements and see what happens. Statements before and/or after. The only thing I can think of is that code optimization is in play. Generally I would not expect that but perhaps that is exactly the cause. If it is an optimization then I would expect the following might fix it (in that Stop will work.)

            String a = null;
            int i = 3;
            a.toUpperCase();
            System.out.println("i=" + i);

            1 Reply Last reply
            0
            • J jschell

              Well that is true specifically but in general it isn't relevant. The code is a valid statement. If it was a different method it might do something. And there is no way the debugger should be figuring that out.

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

              Valid, not valid. He's created an "illogical" scenario what with null assignments, etc. Sorry, I don't blame the compiler or run time. (I frankly have no patience for this type of "nonsense"). And it's hearsay ... Did you "test" it?

              "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

              J 1 Reply Last reply
              0
              • M mike7411

                I am using IntelliJ IDEA 2023.3.1 (Community Edition), and I'm seeing some weirdness. I made a simple test.

                public class SimpleBreakTest {

                public static void main(String\[\] args) {
                    String a = null;
                    a.toUpperCase();
                }
                

                }

                I put a breakpoint on the first line: String a = null; Then, I debugged the program, and it stopped at the breakpoint. Then, I pressed the "Stop" button in the debugger. Instead of stopping execution, it looks like it continued because it printed out this message: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because "a" is null at SimpleBreakTest.main(SimpleBreakTest.java:5) Any ideas why the stop button in the debugger doesn't seem to work right? Thanks.

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

                I am using JDK 18.0.2, and the compiler optimises out those two lines, as they obviously serve no purpose. I cannot find an option to prevent the optimisation. [edit] I had the wrong configuration settings. Tried again and it did exactly the same. I think the debugger stops, but it runs the code to the end of the current method. More tests may help to confirm this. [/edit]

                1 Reply Last reply
                0
                • L Lost User

                  Valid, not valid. He's created an "illogical" scenario what with null assignments, etc. Sorry, I don't blame the compiler or run time. (I frankly have no patience for this type of "nonsense"). And it's hearsay ... Did you "test" it?

                  "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

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

                  All of that is true to the extent that it isn't worth spending time on anyways (which I stated in my other post.)

                  Gerry Schmitz wrote:

                  Did you "test" it?

                  Not relevant. If the OP can replicate it and I can't then nothing is proven. If I can replicate it then it still doesn't change the fact that it is not worth spending time on figuring it out. Not for me at least.

                  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