JDK 12 RFR of JDK-8206085 : Refactor langtools/tools/javac/versions/Versions.java
joe.darcy at oracle.com
Mon Jul 2 23:38:27 UTC 2018
On 7/2/2018 7:36 AM, Peter Levart wrote:
> Hi Joe,
> A suggestion for more compact code: the (ever growing) switch
> statement in enum SourceTarget.checksrc could be replaced with a field
> of type BiConsumer<Versions, String>, initialized in constructor.
> For each enum constant you then just pass a method reference to the
> chosen target method. The checksrc in SourceTarget could be an
> instance method.
I had an intermediate version along those lines before sending the first
one out for review. In the intermediate version, I stored in the method
reference in a field and the enum client code used an accessor method
for it code. The downside was a bit unpleasent to use since the
vararg-ness isn't captured in the generic type. But if checksrc was a
varags instance on the enum, then it could benefit from the varargs
conversion. Let's see ... yes, the resulting test looks better and
should be easier to maintain:
Thank you for the suggestion.
In any case, the span of versions should reduced soon by the removal of
-source/-target/--release 6 in JDK 12 , which is one reason I'm
working on refactoring these tests now :-)
> On 06/29/2018 09:41 PM, joe darcy wrote:
>> Dis-charged revision along with JDK 11 specific source example now up at
>> On 6/29/2018 9:55 AM, Jonathan Gibbons wrote:
>>> There's more static in this file than on my high-school Van de Graaf
>>> Can we follow the convention of creating an instance in main, and
>>> then using instance methods.
>>> The naming of some methods is also novel, with respect to
>>> -- Jon
>>> On 6/28/18 8:15 PM, joe darcy wrote:
>>>> Fresh off of updating
>>>> for the JDK 11 -> 12 transition, I'd like to refactor the test to
>>>> reduce the maintenance needed when adding new versions (as in new
>>>> releases) or removing versions (as is planned for later in JDK 12):
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the compiler-dev