tkalkirill commented on a change in pull request #366:
URL: https://github.com/apache/ignite-3/pull/366#discussion_r739224096
##########
File path:
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/asm/ConfigurationAsmGenerator.java
##########
@@ -555,46 +801,73 @@ else if (isNamedConfigValue(schemaField))
returnType
);
- // result = this.field;
- viewMtd.getBody().append(viewMtd.getThis().getField(fieldDef));
+ BytecodeBlock bytecodeBlock = new BytecodeBlock();
+
+ // result = this.field; OR this.field.field.
+ bytecodeBlock.append(getFieldCodeFun.apply(viewMtd));
- // result = Box.boxValue(result); // Unboxing.
if (schemaFieldType.isPrimitive()) {
- viewMtd.getBody().invokeVirtual(
+ // result = Box.boxValue(result); // Unboxing.
+ bytecodeBlock.invokeVirtual(
box(schemaFieldType),
schemaFieldType.getSimpleName() + "Value",
schemaFieldType
);
}
-
- // retuls = result.clone();
- if (schemaFieldType.isArray())
- viewMtd.getBody().invokeVirtual(schemaFieldType, "clone",
Object.class).checkCast(schemaFieldType);
+ else if (schemaFieldType.isArray()) {
+ // result = result.clone();
+ bytecodeBlock.invokeVirtual(schemaFieldType, "clone",
Object.class).checkCast(schemaFieldType);
+ }
+ else if (isPolymorphicConfig(schemaFieldType) &&
isConfigValue(schemaField)) {
+ // result = result.specificNode();
+ bytecodeBlock.invokeVirtual(SPECIFIC_NODE_MTD);
+ }
// return result;
- viewMtd.getBody().ret(schemaFieldType);
+ bytecodeBlock.ret(schemaFieldType);
+
+ if (getPolymorphicTypeIdFieldFun != null) {
+ assert
isPolymorphicConfigInstance(schemaField.getDeclaringClass()) : schemaField;
+
+ // tmpVar = this.typeId; OR this.field.typeId.
+ BytecodeExpression getPolymorphicTypeIdField =
getPolymorphicTypeIdFieldFun.apply(viewMtd);
+ String polymorphicInstanceId =
polymorphicInstanceId(schemaField.getDeclaringClass());
+
+ // if ("first".equals(tmpVar)) return result;
+ // else throw Ex;
+ viewMtd.getBody().append(
+ new IfStatement()
+
.condition(constantString(polymorphicInstanceId).invoke(STRING_EQUALS_MTD,
getPolymorphicTypeIdField))
+ .ifTrue(bytecodeBlock)
+
.ifFalse(throwException(ConfigurationWrongPolymorphicTypeIdException.class,
getPolymorphicTypeIdField))
Review comment:
There will be a field value and not a name, added postfix Value
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]