Workaround JDK 14 compiler bug (#54689)

This commit workarounds a bug in the JDK 14 compiler. It is choking on a
method reference, so we substitute a lambda expression instead. The JDK
bug ID is 9064309.
This commit is contained in:
Jason Tedor 2020-04-02 19:44:31 -04:00
parent b138dc4565
commit f2590b9984
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
4 changed files with 20 additions and 4 deletions

View File

@ -95,7 +95,11 @@ public class CustomSuggestion extends Suggest.Suggestion<CustomSuggestion.Entry>
static {
declareCommonFields(PARSER);
PARSER.declareString((entry, dummy) -> entry.dummy = dummy, DUMMY);
PARSER.declareObjectArray(Entry::addOptions, (p, c) -> Option.fromXContent(p), new ParseField(OPTIONS));
/*
* The use of a lambda expression instead of the method reference Entry::addOptions is a workaround for a JDK 14 compiler bug.
* The bug ID is 9064309.
*/
PARSER.declareObjectArray((e, o) -> e.addOptions(o), (p, c) -> Option.fromXContent(p), new ParseField(OPTIONS));
}
private String dummy;

View File

@ -269,7 +269,11 @@ public final class CompletionSuggestion extends Suggest.Suggestion<CompletionSug
Entry::new);
static {
declareCommonFields(PARSER);
PARSER.declareObjectArray(Entry::addOptions, (p,c) -> Option.fromXContent(p), new ParseField(OPTIONS));
/*
* The use of a lambda expression instead of the method reference Entry::addOptions is a workaround for a JDK 14 compiler bug.
* The bug ID is 9064309.
*/
PARSER.declareObjectArray((e, o) -> e.addOptions(o), (p,c) -> Option.fromXContent(p), new ParseField(OPTIONS));
}
public static Entry fromXContent(XContentParser parser) {

View File

@ -123,7 +123,11 @@ public class PhraseSuggestion extends Suggest.Suggestion<PhraseSuggestion.Entry>
private static final ObjectParser<Entry, Void> PARSER = new ObjectParser<>("PhraseSuggestionEntryParser", true, Entry::new);
static {
declareCommonFields(PARSER);
PARSER.declareObjectArray(Entry::addOptions, (p, c) -> Option.fromXContent(p), new ParseField(OPTIONS));
/*
* The use of a lambda expression instead of the method reference Entry::addOptions is a workaround for a JDK 14 compiler bug.
* The bug ID is 9064309.
*/
PARSER.declareObjectArray((e, o) -> e.addOptions(o), (p, c) -> Option.fromXContent(p), new ParseField(OPTIONS));
}
public static Entry fromXContent(XContentParser parser) {

View File

@ -188,7 +188,11 @@ public class TermSuggestion extends Suggestion<TermSuggestion.Entry> {
private static final ObjectParser<Entry, Void> PARSER = new ObjectParser<>("TermSuggestionEntryParser", true, Entry::new);
static {
declareCommonFields(PARSER);
PARSER.declareObjectArray(Entry::addOptions, (p,c) -> Option.fromXContent(p), new ParseField(OPTIONS));
/*
* The use of a lambda expression instead of the method reference Entry::addOptions is a workaround for a JDK 14 compiler bug.
* The bug ID is 9064309.
*/
PARSER.declareObjectArray((e, o) -> e.addOptions(o), (p, c) -> Option.fromXContent(p), new ParseField(OPTIONS));
}
public static Entry fromXContent(XContentParser parser) {