diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts
index d32412c066..25e223ab08 100644
--- a/packages/jsii-calc/lib/compliance.ts
+++ b/packages/jsii-calc/lib/compliance.ts
@@ -1221,3 +1221,15 @@ class PrivateImplementation extends ExportedBaseClass implements IPrivatelyImple
super(true);
}
}
+
+/**
+ * Host runtime version should be set via JSII_AGENT
+ */
+export class JsiiAgent {
+ /**
+ * Returns the value of the JSII_AGENT environment variable.
+ */
+ public static get jsiiAgent(): string | undefined {
+ return process.env.JSII_AGENT;
+ }
+};
\ No newline at end of file
diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii
index af67585627..769d2472d7 100644
--- a/packages/jsii-calc/test/assembly.jsii
+++ b/packages/jsii-calc/test/assembly.jsii
@@ -2099,6 +2099,32 @@
}
]
},
+ "jsii-calc.JsiiAgent": {
+ "assembly": "jsii-calc",
+ "docs": {
+ "comment": "Host runtime version should be set via JSII_AGENT"
+ },
+ "fqn": "jsii-calc.JsiiAgent",
+ "initializer": {
+ "initializer": true
+ },
+ "kind": "class",
+ "name": "JsiiAgent",
+ "properties": [
+ {
+ "docs": {
+ "comment": "Returns the value of the JSII_AGENT environment variable."
+ },
+ "immutable": true,
+ "name": "jsiiAgent",
+ "static": true,
+ "type": {
+ "optional": true,
+ "primitive": "string"
+ }
+ }
+ ]
+ },
"jsii-calc.LoadBalancedFargateServiceProps": {
"assembly": "jsii-calc",
"datatype": true,
@@ -3736,5 +3762,5 @@
}
},
"version": "0.7.11",
- "fingerprint": "Nw3vyHfzec4IFe674buqsgL3x8QgvKP0lUC3csRIW7g="
+ "fingerprint": "l8bUuUzVdVn151P/XjDEVN9kHkLfJ+d5fmgZVODpQkg="
}
diff --git a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs
index b609ce9148..203f98160a 100644
--- a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs
+++ b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs
@@ -861,6 +861,12 @@ public void NullShouldBeTreatedAsUndefined()
obj.ChangeMeToUndefined = null;
obj.VerifyPropertyIsUndefined();
}
+
+ [Fact(DisplayName = Prefix + nameof(JsiiAgent))]
+ public void JsiiAgent()
+ {
+ Assert.Equal("DotNet/" + Environment.Version.ToString(), JsiiAgent_.JsiiAgent);
+ }
[Fact(DisplayName = Prefix + nameof(ReceiveInstanceOfPrivateClass))]
public void ReceiveInstanceOfPrivateClass()
diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/NodeProcess.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/NodeProcess.cs
index d18c1281a5..d3f0cd22f3 100644
--- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/NodeProcess.cs
+++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/NodeProcess.cs
@@ -26,6 +26,8 @@ public NodeProcess(IJsiiRuntimeProvider jsiiRuntimeProvider, ILoggerFactory logg
}
};
+ _process.StartInfo.EnvironmentVariables.Add("JSII_AGENT", "DotNet/" + Environment.Version.ToString());
+
_logger.LogDebug("Starting jsii runtime...");
_logger.LogDebug($"{_process.StartInfo.FileName} {_process.StartInfo.Arguments}");
diff --git a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java
index e95a930d31..6840b63f31 100644
--- a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java
+++ b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java
@@ -38,6 +38,7 @@
import software.amazon.jsii.tests.calculator.SyncVirtualMethods;
import software.amazon.jsii.tests.calculator.UnionProperties;
import software.amazon.jsii.tests.calculator.UsesInterfaceWithProperties;
+import software.amazon.jsii.tests.calculator.JsiiAgent;
import software.amazon.jsii.tests.calculator.composition.CompositeOperation;
import software.amazon.jsii.tests.calculator.lib.EnumFromScopedModule;
import software.amazon.jsii.tests.calculator.lib.IFriendly;
@@ -953,6 +954,11 @@ public void nullShouldBeTreatedAsUndefined() {
obj.setChangeMeToUndefined(null);
obj.verifyPropertyIsUndefined();
}
+
+ @Test
+ public void testJsiiAgent() {
+ assertEquals("Java/" + System.getProperty("java.version"), JsiiAgent.getJsiiAgent());
+ }
/**
* @see https://github.com/awslabs/jsii/issues/320
diff --git a/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiRuntime.java b/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiRuntime.java
index d1188026ec..f27d2d6121 100644
--- a/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiRuntime.java
+++ b/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiRuntime.java
@@ -222,6 +222,8 @@ private void startRuntimeIfNeeded() {
if (traceEnabled) {
pb.environment().put("JSII_DEBUG", "1");
}
+
+ pb.environment().put("JSII_AGENT", "Java/" + System.getProperty("java.version"));
try {
this.childProcess = pb.start();
diff --git a/packages/jsii-kernel/test/test.kernel.ts b/packages/jsii-kernel/test/test.kernel.ts
index 7d54fe430f..4b88f84187 100644
--- a/packages/jsii-kernel/test/test.kernel.ts
+++ b/packages/jsii-kernel/test/test.kernel.ts
@@ -959,6 +959,10 @@ defineTest('nulls are converted to undefined - properties', async (_test, sandbo
sandbox.invoke({ objref, method: 'verifyPropertyIsUndefined' });
});
+defineTest('JSII_AGENT is undefined in node.js', async (test, sandbox) => {
+ test.equal(sandbox.sget({ fqn: 'jsii-calc.JsiiAgent', property: 'jsiiAgent' }).value, undefined);
+});
+
// =================================================================================================
const testNames: { [name: string]: boolean } = { };
diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii
index af67585627..769d2472d7 100644
--- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii
+++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii
@@ -2099,6 +2099,32 @@
}
]
},
+ "jsii-calc.JsiiAgent": {
+ "assembly": "jsii-calc",
+ "docs": {
+ "comment": "Host runtime version should be set via JSII_AGENT"
+ },
+ "fqn": "jsii-calc.JsiiAgent",
+ "initializer": {
+ "initializer": true
+ },
+ "kind": "class",
+ "name": "JsiiAgent",
+ "properties": [
+ {
+ "docs": {
+ "comment": "Returns the value of the JSII_AGENT environment variable."
+ },
+ "immutable": true,
+ "name": "jsiiAgent",
+ "static": true,
+ "type": {
+ "optional": true,
+ "primitive": "string"
+ }
+ }
+ ]
+ },
"jsii-calc.LoadBalancedFargateServiceProps": {
"assembly": "jsii-calc",
"datatype": true,
@@ -3736,5 +3762,5 @@
}
},
"version": "0.7.11",
- "fingerprint": "Nw3vyHfzec4IFe674buqsgL3x8QgvKP0lUC3csRIW7g="
+ "fingerprint": "l8bUuUzVdVn151P/XjDEVN9kHkLfJ+d5fmgZVODpQkg="
}
diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsiiAgent_.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsiiAgent_.cs
new file mode 100644
index 0000000000..1c7eec4827
--- /dev/null
+++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsiiAgent_.cs
@@ -0,0 +1,28 @@
+using Amazon.JSII.Runtime.Deputy;
+
+namespace Amazon.JSII.Tests.CalculatorNamespace
+{
+ /// Host runtime version should be set via JSII_AGENT
+ [JsiiClass(typeof(JsiiAgent_), "jsii-calc.JsiiAgent", "[]")]
+ public class JsiiAgent_ : DeputyBase
+ {
+ public JsiiAgent_(): base(new DeputyProps(new object[]{}))
+ {
+ }
+
+ protected JsiiAgent_(ByRefValue reference): base(reference)
+ {
+ }
+
+ protected JsiiAgent_(DeputyProps props): base(props)
+ {
+ }
+
+ /// Returns the value of the JSII_AGENT environment variable.
+ [JsiiProperty("jsiiAgent", "{\"primitive\":\"string\",\"optional\":true}")]
+ public static string JsiiAgent
+ {
+ get => GetStaticProperty(typeof(JsiiAgent_));
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java
index 97f534fd5b..9c641aa5b0 100644
--- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java
+++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java
@@ -61,6 +61,7 @@ protected Class> resolveClass(final String fqn) throws ClassNotFoundException
case "jsii-calc.JSObjectLiteralToNative": return software.amazon.jsii.tests.calculator.JSObjectLiteralToNative.class;
case "jsii-calc.JSObjectLiteralToNativeClass": return software.amazon.jsii.tests.calculator.JSObjectLiteralToNativeClass.class;
case "jsii-calc.JavaReservedWords": return software.amazon.jsii.tests.calculator.JavaReservedWords.class;
+ case "jsii-calc.JsiiAgent": return software.amazon.jsii.tests.calculator.JsiiAgent.class;
case "jsii-calc.LoadBalancedFargateServiceProps": return software.amazon.jsii.tests.calculator.LoadBalancedFargateServiceProps.class;
case "jsii-calc.Multiply": return software.amazon.jsii.tests.calculator.Multiply.class;
case "jsii-calc.MutableObjectLiteral": return software.amazon.jsii.tests.calculator.MutableObjectLiteral.class;
diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsiiAgent.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsiiAgent.java
new file mode 100644
index 0000000000..391d9882a4
--- /dev/null
+++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsiiAgent.java
@@ -0,0 +1,24 @@
+package software.amazon.jsii.tests.calculator;
+
+/**
+ * Host runtime version should be set via JSII_AGENT
+ */
+@javax.annotation.Generated(value = "jsii-pacmak")
+@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.JsiiAgent")
+public class JsiiAgent extends software.amazon.jsii.JsiiObject {
+ protected JsiiAgent(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
+ super(mode);
+ }
+ public JsiiAgent() {
+ super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii);
+ software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this);
+ }
+
+ /**
+ * Returns the value of the JSII_AGENT environment variable.
+ */
+ @javax.annotation.Nullable
+ public static java.lang.String getJsiiAgent() {
+ return software.amazon.jsii.JsiiObject.jsiiStaticGet(software.amazon.jsii.tests.calculator.JsiiAgent.class, "jsiiAgent", java.lang.String.class);
+ }
+}
diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst b/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst
index 55285fbeab..1b330ef898 100644
--- a/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst
+++ b/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst
@@ -2665,6 +2665,47 @@ JavaReservedWords
:type: string
+JsiiAgent
+^^^^^^^^^
+
+.. py:class:: JsiiAgent()
+
+ **Language-specific names:**
+
+ .. tabs::
+
+ .. code-tab:: c#
+
+ using Amazon.JSII.Tests.CalculatorNamespace;
+
+ .. code-tab:: java
+
+ import software.amazon.jsii.tests.calculator.JsiiAgent;
+
+ .. code-tab:: javascript
+
+ const { JsiiAgent } = require('jsii-calc');
+
+ .. code-tab:: typescript
+
+ import { JsiiAgent } from 'jsii-calc';
+
+
+
+ Host runtime version should be set via JSII_AGENT
+
+
+
+
+ .. py:attribute:: jsiiAgent
+
+ Returns the value of the JSII_AGENT environment variable.
+
+
+
+ :type: string *(optional)* *(readonly)* *(static)*
+
+
LoadBalancedFargateServiceProps (interface)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/packages/jsii-runtime/package-lock.json b/packages/jsii-runtime/package-lock.json
index 99f2528db6..afd7d372ca 100644
--- a/packages/jsii-runtime/package-lock.json
+++ b/packages/jsii-runtime/package-lock.json
@@ -1337,11 +1337,13 @@
},
"balanced-match": {
"version": "1.0.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -1354,15 +1356,18 @@
},
"code-point-at": {
"version": "1.1.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -1465,7 +1470,8 @@
},
"inherits": {
"version": "2.0.3",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -1475,6 +1481,7 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -1487,17 +1494,20 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@@ -1514,6 +1524,7 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
+ "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -1586,7 +1597,8 @@
},
"number-is-nan": {
"version": "1.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -1596,6 +1608,7 @@
"once": {
"version": "1.4.0",
"bundled": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -1701,6 +1714,7 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",