At the moment `CompileCommand` and `CompileOnly` use different syntax for 
matching methods. 

### Old CompileOnly format
- matching a **method name** with **class name** and **package name**:
`-XX:CompileOnly=package/path/Class.method`
`-XX:CompileOnly=package/path/Class::method`
`-XX:CompileOnly=package.path.Class::method`
BUT NOT `-XX:CompileOnly=package.path.Class.method`

- just matching a **single method name**:
`-XX:CompileOnly=.hashCode`
`-XX:CompileOnly=::hashCode`
BUT NOT `-XX:CompileOnly=hashCode`

- Matching **all method names** in a **class name** with **package name**
`-XX:CompileOnly=java/lang/String`
BUT NOT `-XX:CompileOnly=java/lang/String.`
BUT NOT `-XX:CompileOnly=java.lang.String`
BUT NOT `-XX:CompileOnly=java.lang.String::` (This is actually a bug) 
BUT NOT `-XX:CompileOnly=String`
BUT NOT `-XX:CompileOnly=String.`
BUT NOT `-XX:CompileOnly=String::`

- Matching **all method names** in a **class name** with **NO package name**
`-XX:CompileOnly=String`
BUT NOT `-XX:CompileOnly=String.`
BUT NOT `-XX:CompileOnly=String::`

- There is a bug when `CompileOnly` ends with `::` where the `CompileOnly` is 
just ignored
e.g. `-XX:CompileOnly=String::` compiles as many methods as when omitting the 
`-XX:CompileOnly=` command

### CompileCommand=compileonly format
`CompileCommand` allows two different forms for paths: 
- `package/path/Class.method`
- `package.path.Class::method`

In contrary to `CompileOnly` `CompileCommand` supports wildcard matching using 
`*`. `*` can appear at the beginning and/or end of a `package.path.Class` and 
`method` name. 

 Valid forms: 
`-XX:CompileCommand=compileonly,*.lang.*::*shCo*`
`-XX:CompileCommand=compileonly,*/lang/*.*shCo*` 
`-XX:CompileCommand=compileonly,java.lang.String::*`
`-XX:CompileCommand=compileonly,*::hashCode`
`-XX:CompileCommand=compileonly,*ng.String::hashC*`
`-XX:CompileCommand=compileonly,*String::hash*`

 Invalid forms (Error: Embedded * not allowed):
 `-XX:CompileCommand=compileonly,java.*.String::has*Code`

### Use CompileCommand syntax for CompileOnly
At the moment, in some cases it is not possible to just take pattern used with 
`CompileOnly` and plug it into compile command file. Syntax used by CompileOnly 
is also not very intuitive. 

`CompileOnly` is convenient because it's shorter to write and takes lists of 
patterns, whereas `CompileCommand` only takes one pattern per command. 

With this PR `CompileOnly` becomes an alias for `CompileCommand=compileonly` 
with possibility to take lists as input. 

New syntax for `CompileOnly`:
- `-XX:CompileOnly=pattern1,pattern2`
is an **alias** for: 
- `-XX:CompileCommand=compileonly,pattern1 
-XX:CompileCommand=compileonly,pattern2`

### Handling invalid syntax
Before `CompileOnly` just ignored invalid syntax. `CompileCommand` at least 
prints an error massage for invalid patterns:

CompileOnly: An error occurred during parsing
Error: Could not parse method pattern
Line: 'pattern'

Since `CompileOnly` now maps to `CompileCommand` is also prints the error 
message for invalid inputs. 
In the future `CompileCommand` (and `CompileOnly`) parsing errors could exit 
the VM https://bugs.openjdk.org/browse/JDK-8282797

### Changed test cases
In the following we mean with `-XX:CompileOnly=oldPattern` -> 
`-XX:CompileOnly=newPattern` that we changed the tests from the `oldPattern` to 
the `newPattern`:
- `Class.method` -> `Class::method` AND `package/path/Class.method` -> 
`package.path.Class::method`
Prefer the `package.path.Class::method` format because it is used by 
`-XX:+PrintCompilation`

- `Class` -> `Class::*`
The `CompileCommand` format requires the `::` to define if `Class` is a class 
name or a method name. 

- `::method` -> `*::method`
The `CompileCommand` format requires the `*`(wildcard) if no class name is 
given. 

- `package/path/Class` -> `package.path.Class::*`
The `CompileCommand` format requires the `*`(wildcard) if no method name is 
given. 
Prefer the `package.path.Class::method` format because it is used by 
`-XX:+PrintCompilation`

- `::get,::get1` -> `*Class::get*`
The `CompileCommand` format requires the `*`(wildcard) if no method name is 
given. Therefore `*::get` would work as well, but this matches many other 
methods as well like `java.util.HashMap::get`.
`*Class::get,*Class::get1` matches the wanted class name - `*Class::get*` is 
just the short form. 

- `package/path/Class::method` -> `package.path.Class::method`
The old format of `CompileOnly` combining `/` with `::`. 
The `CompileCommand` is either `package/path/Class.method` or 
`package.path.Class::method`. 

- _BUG_: `package.path.Class::` -> `package.path.Class::*`
There was a bug in the old format of `CompileOnly` : when the pattern ended 
with `::` the `CompileOnly` was just ignored and all methods compiled. The 
`CompileCommand` format requires the `*`(wildcard) if no method name is given.

-------------

Commit messages:
 - Updated copyright
 - fix CompileOnly tests
 - JDK-8027711: Unify wildcarding syntax for CompileCommand and CompileOnly

Changes: https://git.openjdk.org/jdk/pull/13802/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13802&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8027711
  Stats: 376 lines in 71 files changed: 29 ins; 73 del; 274 mod
  Patch: https://git.openjdk.org/jdk/pull/13802.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13802/head:pull/13802

PR: https://git.openjdk.org/jdk/pull/13802

Reply via email to