-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
17
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Appears in OpenJDK 17.0.5 and Corretto 17.0.4. May appear on other releases.
A DESCRIPTION OF THE PROBLEM :
Similar symptoms toJDK-8132535, with three differences:
1. Appears in 17.0.x and presumably other releases.
2. Is triggered when offending class is declared as a record.
3. Offending class is not a diamond, but probably has some other interesting characteristic (it doesn't happen for all records).
Tested on MacOS and Linux.
REGRESSION : Last worked in version 13
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compiler crashes when a record like this is found as an inner class or top level class. Workaround class is the following; convert it to a record to cause it to trigger the compiler error:
{{{
private class FieldMod<T> {
private final String name;
private final Function<? super JsonNode, ? extends T> nodeValue;
private final Function<? super NotificationRule, ? extends T> originalValue;
private final BiFunction<? super NotificationRuleBuilder, ? super T, ? extends NotificationRuleBuilder> builderFunction;
public FieldMod(
String name,
Function<? super JsonNode, ? extends T> nodeValue,
Function<? super NotificationRule, ? extends T> originalValue,
BiFunction<? super NotificationRuleBuilder, ? super T, ? extends NotificationRuleBuilder> builderFunction) {
this.name = name;
this.nodeValue = nodeValue;
this.originalValue = originalValue;
this.builderFunction = builderFunction;
}
public static <T> FieldMod<T> of(
String name,
Function<? super JsonNode, ? extends T> nodeValue,
Function<? super NotificationRule, ? extends T> originalValue,
BiFunction<? super NotificationRuleBuilder, ? super T, ? extends NotificationRuleBuilder> builderFunction) {
return new FieldMod<>(name, nodeValue, originalValue, builderFunction);
}
/**
* If the node has the field of the given name, apply the value from the node (non-null to set, null to remove)
* to the builder and return the resulting builder. If the node doesn't have the field of the given name, but
* the original has a non-null value for it, apply the value from the original to the builder and return the
* resulting builder. If neither node nor original have the field of the given name, return the unchanged
* builder.
*/
public NotificationRuleBuilder apply(
NotificationRuleBuilder builder, ObjectNode delta, NotificationRule original) {
if (delta.has(name)) {
var fieldValueNode = delta.get(name);
if (fieldValueNode instanceof NullNode) {
return builderFunction.apply(builder, null);
} else {
T value = nodeValue.apply(fieldValueNode);
return builderFunction.apply(builder, value);
}
} else {
T value = originalValue.apply(original);
if (value != null) {
return builderFunction.apply(builder, value);
} else {
return builder;
}
}
}
}
}}}
JsonNode, ObjectNode, and NullNode are from the Jackson library, NotificationRule is an entity class (POJO annotated as a Hibernate entity), and NotificationRuleBuilder is a Lombok-created builder for NotificationRule.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation or informative error message.
ACTUAL -
java.lang.AssertionError: typeSig ERROR during compilation.
CUSTOMER SUBMITTED WORKAROUND :
Convert record to ordinary class.
FREQUENCY : always
Appears in OpenJDK 17.0.5 and Corretto 17.0.4. May appear on other releases.
A DESCRIPTION OF THE PROBLEM :
Similar symptoms to
1. Appears in 17.0.x and presumably other releases.
2. Is triggered when offending class is declared as a record.
3. Offending class is not a diamond, but probably has some other interesting characteristic (it doesn't happen for all records).
Tested on MacOS and Linux.
REGRESSION : Last worked in version 13
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compiler crashes when a record like this is found as an inner class or top level class. Workaround class is the following; convert it to a record to cause it to trigger the compiler error:
{{{
private class FieldMod<T> {
private final String name;
private final Function<? super JsonNode, ? extends T> nodeValue;
private final Function<? super NotificationRule, ? extends T> originalValue;
private final BiFunction<? super NotificationRuleBuilder, ? super T, ? extends NotificationRuleBuilder> builderFunction;
public FieldMod(
String name,
Function<? super JsonNode, ? extends T> nodeValue,
Function<? super NotificationRule, ? extends T> originalValue,
BiFunction<? super NotificationRuleBuilder, ? super T, ? extends NotificationRuleBuilder> builderFunction) {
this.name = name;
this.nodeValue = nodeValue;
this.originalValue = originalValue;
this.builderFunction = builderFunction;
}
public static <T> FieldMod<T> of(
String name,
Function<? super JsonNode, ? extends T> nodeValue,
Function<? super NotificationRule, ? extends T> originalValue,
BiFunction<? super NotificationRuleBuilder, ? super T, ? extends NotificationRuleBuilder> builderFunction) {
return new FieldMod<>(name, nodeValue, originalValue, builderFunction);
}
/**
* If the node has the field of the given name, apply the value from the node (non-null to set, null to remove)
* to the builder and return the resulting builder. If the node doesn't have the field of the given name, but
* the original has a non-null value for it, apply the value from the original to the builder and return the
* resulting builder. If neither node nor original have the field of the given name, return the unchanged
* builder.
*/
public NotificationRuleBuilder apply(
NotificationRuleBuilder builder, ObjectNode delta, NotificationRule original) {
if (delta.has(name)) {
var fieldValueNode = delta.get(name);
if (fieldValueNode instanceof NullNode) {
return builderFunction.apply(builder, null);
} else {
T value = nodeValue.apply(fieldValueNode);
return builderFunction.apply(builder, value);
}
} else {
T value = originalValue.apply(original);
if (value != null) {
return builderFunction.apply(builder, value);
} else {
return builder;
}
}
}
}
}}}
JsonNode, ObjectNode, and NullNode are from the Jackson library, NotificationRule is an entity class (POJO annotated as a Hibernate entity), and NotificationRuleBuilder is a Lombok-created builder for NotificationRule.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation or informative error message.
ACTUAL -
java.lang.AssertionError: typeSig ERROR during compilation.
CUSTOMER SUBMITTED WORKAROUND :
Convert record to ordinary class.
FREQUENCY : always
- relates to
-
JDK-8132535 Compiler fails with diamond anonymous class creation with intersection bound of enclosing class
-
- Closed
-