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

String concatenation fails with implicit toString() on package-private class

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 9
    • 9
    • tools
    • None
    • 9
    • b110
    • x86_64
    • linux_oracle_6.0
    • Verified

    Description

      JCK build fails with new jdk9 builds that optimize string concatenation.
      The use case is reduced to:

      ---- JTF_Slot.java ----
      package p1;
      public class JTF_Slot { public Hold cls_decl = new Hold();}
      class Hold { public String toString() {return "passed"; }}

      ---- test.java ----
      public class test {
          public static void main(String[] argv) {
              p1.JTF_Slot mainRoot = new p1.JTF_Slot();
              System.out.println(""+(mainRoot.cls_decl)+"");
          }
      }

      > java -version
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+108-2016-03-02-173138.javare.4571)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+108-2016-03-02-173138.javare.4571, mixed mode)

      > javac -XDstringConcat=inline -cp . -d . JTF_Slot.java test.java ; java -cp . test
      passed

      > javac -cp . -d . JTF_Slot.java test.java ; java -cp . test
      Exception in thread "main" java.lang.BootstrapMethodError: java.lang.IllegalAccessError: tried to access class p1.Hold from class test
      at test.main(test.java:4)
      Caused by: java.lang.IllegalAccessError: tried to access class p1.Hold from class test
      ... 1 more
      > hostname
      scaaa744

      Attachments

        Activity

          People

            shade Aleksey Shipilev
            larbouzo Leonid Arbuzov
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: