JDK-8074095 : Method validation in CompileCommand
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-03-02
  • Updated: 2015-09-18
  • Resolved: 2015-09-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Description
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
...
Comments
Fix by: 8135068
18-09-2015

Here is another validation issue: For some invalid patterns CompileBroker makes all methods be non-compilable: Here is an example where it compiles all methods $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand=compileonly,java/lang/indexOf -XX:+PrintCompilation -version CompileCommand: Bad pattern "compileonly java/lang/indexOf" Unrecognized text java/lang/indexOf after command Usage: '-XX:CompileCommand=command,"package/Class.method()"' Use: '-XX:CompileCommand=help' for more information. 58 1 !b 3 java.lang.invoke.MethodHandle::<clinit> (45 bytes) 72 2 !b 4 java.lang.invoke.MethodHandle::<clinit> (45 bytes) 106 1 ! 3 java.lang.invoke.MethodHandle::<clinit> (45 bytes) made not entrant 107 3 !b 2 java.lang.Class::desiredAssertionStatus (54 bytes) 119 4 n 0 java.lang.Class::desiredAssertionStatus0 (native) (static) 120 5 b 3 java.lang.invoke.MethodHandleImpl::<clinit> (110 bytes) 121 6 b 4 java.lang.invoke.MethodHandleImpl::<clinit> (110 bytes) .... 293 187 3 java.lang.Shutdown::<clinit> (43 bytes) made not entrant 293 189 b 3 java.lang.Shutdown$Lock::<init> (5 bytes) 293 190 b 4 java.lang.Shutdown$Lock::<init> (5 bytes) 294 189 3 java.lang.Shutdown$Lock::<init> (5 bytes) made not entrant 295 191 b 2 java.lang.Shutdown$Lock::<init> (5 bytes) 295 192 !b 3 java.lang.Shutdown::shutdown (72 bytes) 296 193 !b 4 java.lang.Shutdown::shutdown (72 bytes) 298 192 ! 3 java.lang.Shutdown::shutdown (72 bytes) made not entrant 298 194 !b 2 java.lang.Shutdown::sequence (61 bytes) 299 195 !b 2 java.lang.Shutdown::runHooks (69 bytes) And this is an example where it doesn't compile any method $ /java/9/promoted/b51/jdk1.9.0/bin/java -Xcomp -XX:CompileCommand=compileonly,java::lang::String::indexOf -XX:+PrintCompilation -version CompileCommand: Bad pattern "compileonly java lang String indexOf" Unrecognized text String indexOf after command Usage: '-XX:CompileCommand=command,"package/Class.method()"' Use: '-XX:CompileCommand=help' for more information. 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)
12-03-2015

ILW=Bad validation in compilecommand, always, none=LHH=P5
04-03-2015