Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8212664

StringReferenceImpl may cache value before the constructor is finished

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: tbd
    • Component/s: core-svc
    • Labels:
      None

      Description

      Steps to reproduce:
      - step into a String(String) constructor with not empty inital value
      - print "this" value (result is an empty string)
      - step out of the constructor
      - print the created String variable value (result is an empty string again)

      Sample code:
      package my.render;

      public class StringRender {
          public static void main(String[] args) {
              String a = "xxxcvsdfsd".substring(1);
              System.out.println(a);
          }
      }

      sample jdb session:
      >jdb my.render.StringRender
      Initializing jdb ...
      > exclude none
      > stop at my.render.StringRender:5
      Deferring breakpoint my.render.StringRender:5.
      It will be set after the class is loaded.
      > run
      run my.render.StringRender
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      >
      VM Started: Set deferred breakpoint my.render.StringRender:5

      Breakpoint hit: "thread=main", my.render.StringRender.main(), line=5 bci=0

      main[1] step
      >
      Step completed: "thread=main", java.lang.String.substring(), line=1,926 bci=0

      main[1] step
      >
      Step completed: "thread=main", java.lang.String.substring(), line=1,929 bci=13

      main[1] step
      >
      Step completed: "thread=main", java.lang.String.substring(), line=1,930 bci=21

      main[1] step
      >
      Step completed: "thread=main", java.lang.String.substring(), line=1,933 bci=34

      main[1] step
      >
      Step completed: "thread=main", java.lang.String.<init>(), line=190 bci=0

      main[1] print this
       this = ""
      main[1] stop at my.render.StringRender:6
      Set breakpoint my.render.StringRender:6
      main[1] cont
      >
      Breakpoint hit: "thread=main", my.render.StringRender.main(), line=6 bci=7

      main[1] print a
       a = ""
      main[1] cont
      > xxcvsdfsd

      The application exited

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eushakov Egor Ushakov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: