-
Couldn't load subscription status.
- Fork 257
Closed
Labels
bugThis issue is a bug.This issue is a bug.in-progressIssue is being actively worked on.Issue is being actively worked on.language/javaRelated to Java bindingsRelated to Java bindingsmodule/runtimeIssues affecting the `jsii-runtime`Issues affecting the `jsii-runtime`p1
Description
🐛 Bug Report
Affected Languages
-
TypeScriptorJavascript -
Python -
Java - .NET (
C#,F#, ...)
General Information
- JSII Version:
0.21.1 (build 9ff44cb), typescript 3.7.4 - Platform: any
What is the problem?
When a return value is typed as a List<SomeStruct>, the Java runtime does not correctly perform the conversion to the correct Java type, and instead returns a List<JsiiObject> where the JsiiObject instances however contain all the information necessary to permit the conversion.
The runtime needs to be corrected so that it actually returns a List<SomeStruct>, or else attempting to use the contents of the list is likely to cause a ClassCastException.
It is probable the same issue would affect Map<String, SomeStruct> instances, so this has to be checked as well.
Minimal Reproduction
A minimal reproduction using the AWS CDK can be achieved:
package com.myorg;
import software.amazon.awscdk.core.*;
import software.amazon.awscdk.services.cloudwatch.Dimension;
import software.amazon.awscdk.services.cloudwatch.IMetric;
import software.amazon.awscdk.services.cloudwatch.MetricConfig;
import software.amazon.awscdk.services.lambda.Code;
import software.amazon.awscdk.services.lambda.Function;
import software.amazon.awscdk.services.lambda.Runtime;
import java.util.List;
public class CwMetricsApp {
public static void main(final String[] args) {
final App app = new App();
final Stack stack = new Stack(app, "ReproStack");
final Function funct = Function.Builder.create(stack, "Function")
.code(Code.fromInline("export function handler() {}"))
.handler("index.handler")
.runtime(Runtime.NODEJS_10_X)
.build();
final IMetric metric = funct.metricInvocations();
final MetricConfig config = metric.toMetricConfig();
// This list is, in fact (and incorrectly), a List<JsiiObject>
final List<Dimension> dimensions = config.getMetricStat().getDimensions();
for (final Dimension dimension : dimensions) {
System.out.println(String.format("Dimension<%s, %s>", dimension.getName(), dimension.getValue()));
}
app.synth();
}
}haiko
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.in-progressIssue is being actively worked on.Issue is being actively worked on.language/javaRelated to Java bindingsRelated to Java bindingsmodule/runtimeIssues affecting the `jsii-runtime`Issues affecting the `jsii-runtime`p1