On Mon, 13 Dec 2021 16:50:34 GMT, Pavel Rappo <pra...@openjdk.org> wrote:

>> Jonathan Gibbons has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   update to handle methods on JavaFileManager, such as getFileForInput
>>   
>>   Overall, to better handle the ability to throw checked exceptions,
>>   the functionality of the builder is changed and now limited to providing
>>   functions that can throw user-provided exceptions, instead of fully
>>   replacing the underlying delegate method.
>
> test/langtools/jdk/javadoc/lib/javadoc/tester/TestJavaFileManagerBuilder.java 
> line 142:
> 
>> 140: 
>> 141:         var map = fileObjectHandlers.computeIfAbsent(filter, p_ -> new 
>> HashMap<>());
>> 142:         var prev = map.put(method, handler);
> 
> Keying by a predicate has unclear semantics. It is unlikely that 
> `filter1.equals(filter2)` will work as we might expect it to.

I've modified the API so that it is no longer necessary to use the predicate as 
a key.

Instead, the map is no longer built incrementally by a series of `handle` 
calls;  the signature of the `handle` call is modified to take the predicate 
and a user-provided map.  It is expected that maps will be small (typically one 
element) and easy to create with `Map.of`.    While this specifically applies 
to the handling of file objects, for consistency a similar change is made to 
the API to register handlers for file manager calls.

Also of note, because this removes the need to create the maps within the 
builder class, the other issue about using `putIfAbsent` instead of `put` is 
now moot.

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

PR: https://git.openjdk.java.net/jdk/pull/6404

Reply via email to