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

Method validation in CompileCommand

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 9
    • 9
    • hotspot
    • None

      In some cases CompileCommand doesn't fail when some invalid method names are passed:

      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='compileonly::java.lang/Str/i.ng::::*a/a.b:(abc))def' -XX:+PrintCompilation -version
      CompileCommand: compileonly java/lang/Str/i/ng.*a/a/b(abc))def
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b51)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b51, compiled mode)

      1. It doesn't validate usage of :: (double colon)
      In the example it is used as a separator between command and method, and two times between "ng" and "*a". As double colon is a separator between class and method it shouldn't be allowed to use any separators like slash or dot. Method identifier shouldn't have any dots or slashes, see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2

      Also it allows to use a single : just replacing it with a space symbol or ignoring it (see : before (abc))

      2. CompileCommand allows to mix dot and slash symbols in package/class
      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='compileonly,java.lang/String::index*' -XX:+PrintCompilation -version
      CompileCommand: compileonly java/lang/String.index*

      but:
      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='compileonly,java.lang/String.index*' -XX:+PrintCompilation -version
      CompileCommand: Bad pattern
        "compileonly java lang/String index*"
        Unrecognized text index* after command

      Usage: '-XX:CompileCommand=command,"package/Class.method()"'
      Use: '-XX:CompileCommand=help' for more information.

      3. Signature validation:
      In the example CompileCommand allows to pass (Isd)I as a signature, it doesn't warn and doesn't match any method
      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='compileonly,java/lang/String.index*(Isd)I' -XX:+PrintCompilation -version
      CompileCommand: compileonly java/lang/String.index*(Isd)I
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b51)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b51, compiled mode)

      4. quite and help commands allow to specify anything after command. This is a minor issue

      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='quiet|' -XX:CompileCommand='compileonly,java/lang/String.indexOf' -version
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b51)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b51, compiled mode)

      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='quiet3' -XX:CompileCommand='compileonly,java/lang/String.indexOf' -version
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b51)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b51, compiled mode)

      $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand='help3' -XX:CompileCommand='compileonly,java/lang/String.indexOf' -version

      The CompileCommand option enables the user of the JVM to control specific
      behavior of the dynamic compilers. Many commands require a pattern that defines
      ...

            neliasso Nils Eliasson (Inactive)
            ppunegov Pavel Punegov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: