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

Class.forName transforms class name in ClassNotFoundException for invalid names

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      When Class.forName is called with a name which is invalid, the class name reported by the ClassNotFoundException exception uses the JVM notation of the class (replacing periods with slashes). This can be irritating because Class.forName normally reports the requested class name in the ClassNotFoundException.

      The following lists the passed in class name string, and the class name reported by ClassNotFoundException in the line below it.

      Working as expected:
          "Ldoes.not.Exist"
              -> "Ldoes.not.Exist"
          "Ldoes.not/Exist;"
              -> "Ldoes.not/Exist;"
          "does.not/Exist"
              -> "does.not/Exist"
          "does.not Exist"
              -> "does.not Exist"
          "[Ldoes.not.Exist;"
              -> "does.not.Exist"
              Component type does not exist
          
      Not working as expected:
          "does.not.Exist;"
              -> "does/not/Exist;"
              Converted '.' -> '/'
          "does.not.Exist["
              -> "does/not/Exist["
              Converted '.' -> '/'
          "java.lang.String\u0000"
              -> "java/lang/String "
              Converted '.' -> '/'
          "[".repeat(256) + "Ldoes.not.Exist;"
              -> "...[[Ldoes/not/Exist;"
              Converted '.' -> '/'



            bchristi Brent Christian
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: