From dbbc137f0213cc27f157fb226d9aaea87e8fe344 Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Wed, 21 Feb 2024 14:31:48 +0530 Subject: [PATCH 1/7] Add ExternalDependency annotation --- .../jballerina.java/src/main/ballerina/annotations.bal | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/langlib/jballerina.java/src/main/ballerina/annotations.bal b/langlib/jballerina.java/src/main/ballerina/annotations.bal index dc6ca4e32c44..103bedad3b07 100644 --- a/langlib/jballerina.java/src/main/ballerina/annotations.bal +++ b/langlib/jballerina.java/src/main/ballerina/annotations.bal @@ -126,3 +126,12 @@ public const annotation FieldData FieldSet on source external; # } # ``` public const annotation ObjectData Binding on class; + +# Describes a type, class or function that is a dependency of java native code. +# ```ballerina +# @externalDependency +# function foo(int x) returns int { +# return x * 2; +# } +# ``` +public const annotation ExternalDependency on source type, source class, source function; From ab88387eaa7228d5217f999174813d896af4e7ca Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Wed, 21 Feb 2024 14:49:09 +0530 Subject: [PATCH 2/7] Fix annotation documentation --- langlib/jballerina.java/src/main/ballerina/annotations.bal | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/langlib/jballerina.java/src/main/ballerina/annotations.bal b/langlib/jballerina.java/src/main/ballerina/annotations.bal index 103bedad3b07..51262a8e3988 100644 --- a/langlib/jballerina.java/src/main/ballerina/annotations.bal +++ b/langlib/jballerina.java/src/main/ballerina/annotations.bal @@ -127,9 +127,10 @@ public const annotation FieldData FieldSet on source external; # ``` public const annotation ObjectData Binding on class; -# Describes a type, class or function that is a dependency of java native code. +# Describes a type, class or function that is a dependency of java native code. This annotation should be added by the +# developer if a type definition is being accessed by a `io.ballerina.runtime.api.creators` api such as `ValueCreator`. # ```ballerina -# @externalDependency +# @ExternalDependency # function foo(int x) returns int { # return x * 2; # } From 172e23620ca97e21e247425a2f05e1544d4a9ecd Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Wed, 21 Feb 2024 17:46:29 +0530 Subject: [PATCH 3/7] Add test cases for ExternalDependency annotation --- .../ExternalDependencyAnnotationTest.java | 68 +++++++++++++++++ .../external_dependency_annotation.bal | 76 +++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java new file mode 100644 index 000000000000..fd6a71a6ea6c --- /dev/null +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.ballerinalang.test.annotations; + +import org.ballerinalang.test.BCompileUtil; +import org.ballerinalang.test.CompileResult; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.ballerinalang.compiler.tree.BLangPackage; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * Class to test ExternalDependency annotation. + * + * @since 2.0 + */ +@Test +public class ExternalDependencyAnnotationTest { + + private BLangPackage pkgNode; + + @BeforeClass + public void setup() { + CompileResult result = BCompileUtil.compile("test-src/annotations/external_dependency_annotation.bal"); + pkgNode = (BLangPackage) result.getAST(); + } + + @Test(description = "Test the ExternalDependency annotation used on functions") + public void testExternalDependencyAnnotOnFunctions() { + assertEquals(pkgNode.functions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(pkgNode.functions.get(1).annAttachments.isEmpty()); + assertEquals(pkgNode.functions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(pkgNode.functions.get(3).annAttachments.isEmpty()); + } + + @Test(description = "Test the ExternalDependency annotation used on classes") + public void testExternalDependencyAnnotOnClasses() { + assertEquals(pkgNode.classDefinitions.get(1).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(pkgNode.classDefinitions.get(2).annAttachments.isEmpty()); + } + + @Test(description = "Test the ExternalDependency annotation used on type definitions") + public void testExternalDependencyAnnotOnTypeDefinitions() { + assertEquals(pkgNode.typeDefinitions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(pkgNode.typeDefinitions.get(1).annAttachments.isEmpty()); + assertEquals(pkgNode.typeDefinitions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(pkgNode.typeDefinitions.get(3).annAttachments.isEmpty()); + assertEquals(pkgNode.typeDefinitions.get(4).annAttachments.get(1).annotationName.value, "ExternalDependency"); + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal new file mode 100644 index 000000000000..d28c4e86fbd0 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal @@ -0,0 +1,76 @@ +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/jballerina.java; + +// Functions +@java:ExternalDependency +function foo(int x) returns int { + return x * 2; +} + +function bar() returns string { + return "bar"; +} + +// Attached functions +class CorgeClass { + + @java:ExternalDependency + function externalCorge() returns string { + return "external corge"; + } + + function corge() returns string { + return "corge"; + } +} + +// Classes +@java:ExternalDependency +class BazClass { + int x = 0; + string y = ""; +} + +class QuzClass { + int x = 0; + string y = ""; +} + +// Records +@java:ExternalDependency +type FooRec record { + int x; + string y; +}; + +type BarRec record { + int x; + string y; +}; + +// Type Definitions +@java:ExternalDependency +type FooType int|string; + +type BarType int|string; + +// Edge cases +@deprecated +@java:ExternalDependency +@tainted +type CorgeType int|string; From 2096356dd93234773576da55c0228da4eab16eba Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Thu, 22 Feb 2024 10:21:30 +0530 Subject: [PATCH 4/7] Fix review suggestions --- .../ExternalDependencyAnnotationTest.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java index fd6a71a6ea6c..4d21dd89633b 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java @@ -22,7 +22,12 @@ import org.ballerinalang.test.CompileResult; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; +import org.wso2.ballerinalang.compiler.tree.BLangFunction; import org.wso2.ballerinalang.compiler.tree.BLangPackage; +import org.wso2.ballerinalang.compiler.tree.BLangTypeDefinition; + +import java.util.List; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -30,7 +35,7 @@ /** * Class to test ExternalDependency annotation. * - * @since 2.0 + * @since 2201.9.0 */ @Test public class ExternalDependencyAnnotationTest { @@ -45,24 +50,27 @@ public void setup() { @Test(description = "Test the ExternalDependency annotation used on functions") public void testExternalDependencyAnnotOnFunctions() { - assertEquals(pkgNode.functions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(pkgNode.functions.get(1).annAttachments.isEmpty()); - assertEquals(pkgNode.functions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(pkgNode.functions.get(3).annAttachments.isEmpty()); + List functions = pkgNode.functions; + assertEquals(functions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(functions.get(1).annAttachments.isEmpty()); + assertEquals(functions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(functions.get(3).annAttachments.isEmpty()); } @Test(description = "Test the ExternalDependency annotation used on classes") public void testExternalDependencyAnnotOnClasses() { - assertEquals(pkgNode.classDefinitions.get(1).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(pkgNode.classDefinitions.get(2).annAttachments.isEmpty()); + List classDefinitions = pkgNode.classDefinitions; + assertEquals(classDefinitions.get(1).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(classDefinitions.get(2).annAttachments.isEmpty()); } @Test(description = "Test the ExternalDependency annotation used on type definitions") public void testExternalDependencyAnnotOnTypeDefinitions() { - assertEquals(pkgNode.typeDefinitions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(pkgNode.typeDefinitions.get(1).annAttachments.isEmpty()); - assertEquals(pkgNode.typeDefinitions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(pkgNode.typeDefinitions.get(3).annAttachments.isEmpty()); - assertEquals(pkgNode.typeDefinitions.get(4).annAttachments.get(1).annotationName.value, "ExternalDependency"); + List typeDefinitions = pkgNode.typeDefinitions; + assertEquals(typeDefinitions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(typeDefinitions.get(1).annAttachments.isEmpty()); + assertEquals(typeDefinitions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); + assertTrue(typeDefinitions.get(3).annAttachments.isEmpty()); + assertEquals(typeDefinitions.get(4).annAttachments.get(1).annotationName.value, "ExternalDependency"); } } From e47ec5656e6ec1e9e58f308bbfc4270e8238a31e Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Thu, 22 Feb 2024 11:11:48 +0530 Subject: [PATCH 5/7] Add negative tests for ExternalDependency annot --- ...ernalDependencyAnnotationNegativeTest.java | 45 +++++++++++++++++++ ...xternal_dependency_annotation_negative.bal | 24 ++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationNegativeTest.java create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation_negative.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationNegativeTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationNegativeTest.java new file mode 100644 index 000000000000..d39865c7b59a --- /dev/null +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationNegativeTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.ballerinalang.test.annotations; + +import org.ballerinalang.test.BAssertUtil; +import org.ballerinalang.test.BCompileUtil; +import org.ballerinalang.test.CompileResult; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Negative tests for ExternalDependency annotation. + * + * @since 2201.9.0 + */ +public class ExternalDependencyAnnotationNegativeTest { + + @Test(description = "Negative tests for ExternalDependency annotation") + public void testExternalDependencyAnnotation() { + CompileResult compileResult = + BCompileUtil.compile("test-src/annotations/external_dependency_annotation_negative.bal"); + int i = 0; + BAssertUtil.validateError(compileResult, i++, + "annotation 'ballerina/jballerina.java:0.0.0:ExternalDependency' is not allowed on var", 20, 1); + BAssertUtil.validateError(compileResult, i++, + "annotation 'ballerina/jballerina.java:0.0.0:ExternalDependency' is not allowed on const", 23, 1); + Assert.assertEquals(compileResult.getErrorCount(), i); + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation_negative.bal new file mode 100644 index 000000000000..a78325e538ff --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation_negative.bal @@ -0,0 +1,24 @@ +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/jballerina.java; + +// Types not allowed as sources for ExternalDependency annotation +@java:ExternalDependency +var varType = (); + +@java:ExternalDependency +const string constType = "Im not an external dependency"; From 13d72cd2d546cc92e7d6247b667e38bcdd718914 Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Mon, 26 Feb 2024 11:27:54 +0530 Subject: [PATCH 6/7] Refactor according to review suggestions --- .../src/main/ballerina/annotations.bal | 11 +++-- .../ExternalDependencyAnnotationTest.java | 27 ++++++------ .../external_dependency_annotation.bal | 41 +------------------ 3 files changed, 21 insertions(+), 58 deletions(-) diff --git a/langlib/jballerina.java/src/main/ballerina/annotations.bal b/langlib/jballerina.java/src/main/ballerina/annotations.bal index 51262a8e3988..44e62a53a58a 100644 --- a/langlib/jballerina.java/src/main/ballerina/annotations.bal +++ b/langlib/jballerina.java/src/main/ballerina/annotations.bal @@ -127,12 +127,11 @@ public const annotation FieldData FieldSet on source external; # ``` public const annotation ObjectData Binding on class; -# Describes a type, class or function that is a dependency of java native code. This annotation should be added by the -# developer if a type definition is being accessed by a `io.ballerina.runtime.api.creators` api such as `ValueCreator`. +# Identifies a type, class, or function that is used in the Java native code. This annotation should be added by the +# developer if the type, class, or function could be accessed via an `io.ballerina.runtime.api.creators` API such as +# `ValueCreator`. # ```ballerina -# @ExternalDependency -# function foo(int x) returns int { -# return x * 2; -# } +# @java:ExternalDependency +# function foo(int x) returns int => x * 2; # ``` public const annotation ExternalDependency on source type, source class, source function; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java index 4d21dd89633b..57957ef63af6 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java @@ -18,16 +18,18 @@ package org.ballerinalang.test.annotations; +import org.ballerinalang.model.elements.AttachPoint; import org.ballerinalang.test.BCompileUtil; import org.ballerinalang.test.CompileResult; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; import org.wso2.ballerinalang.compiler.tree.BLangFunction; import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangTypeDefinition; +import java.util.Arrays; import java.util.List; +import java.util.Set; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -37,7 +39,6 @@ * * @since 2201.9.0 */ -@Test public class ExternalDependencyAnnotationTest { private BLangPackage pkgNode; @@ -48,29 +49,31 @@ public void setup() { pkgNode = (BLangPackage) result.getAST(); } + @Test(description = "Test the ExternalDependency annotation attach points") + public void testExternalDependencyAttachPoints() { + Set attachPoints = pkgNode.functions.get(0).annAttachments.get(0).annotationSymbol.points; + List expectedAttachPoints = Arrays.asList("type", "class", "function"); + + assertEquals(attachPoints.size(), 3); + assertTrue(attachPoints.stream() + .allMatch(attachPoint -> expectedAttachPoints.contains(attachPoint.point.getValue()))); + } + @Test(description = "Test the ExternalDependency annotation used on functions") public void testExternalDependencyAnnotOnFunctions() { List functions = pkgNode.functions; assertEquals(functions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(functions.get(1).annAttachments.isEmpty()); - assertEquals(functions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(functions.get(3).annAttachments.isEmpty()); } @Test(description = "Test the ExternalDependency annotation used on classes") public void testExternalDependencyAnnotOnClasses() { - List classDefinitions = pkgNode.classDefinitions; - assertEquals(classDefinitions.get(1).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(classDefinitions.get(2).annAttachments.isEmpty()); + assertEquals(pkgNode.classDefinitions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); } @Test(description = "Test the ExternalDependency annotation used on type definitions") public void testExternalDependencyAnnotOnTypeDefinitions() { List typeDefinitions = pkgNode.typeDefinitions; assertEquals(typeDefinitions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(typeDefinitions.get(1).annAttachments.isEmpty()); - assertEquals(typeDefinitions.get(2).annAttachments.get(0).annotationName.value, "ExternalDependency"); - assertTrue(typeDefinitions.get(3).annAttachments.isEmpty()); - assertEquals(typeDefinitions.get(4).annAttachments.get(1).annotationName.value, "ExternalDependency"); } } + diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal index d28c4e86fbd0..6f4eed16e490 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/external_dependency_annotation.bal @@ -22,23 +22,6 @@ function foo(int x) returns int { return x * 2; } -function bar() returns string { - return "bar"; -} - -// Attached functions -class CorgeClass { - - @java:ExternalDependency - function externalCorge() returns string { - return "external corge"; - } - - function corge() returns string { - return "corge"; - } -} - // Classes @java:ExternalDependency class BazClass { @@ -46,31 +29,9 @@ class BazClass { string y = ""; } -class QuzClass { - int x = 0; - string y = ""; -} - -// Records +// Type Definitions @java:ExternalDependency type FooRec record { int x; string y; }; - -type BarRec record { - int x; - string y; -}; - -// Type Definitions -@java:ExternalDependency -type FooType int|string; - -type BarType int|string; - -// Edge cases -@deprecated -@java:ExternalDependency -@tainted -type CorgeType int|string; From 8ee99e124cd9ebf03c9c475c029645ffef5ecbaa Mon Sep 17 00:00:00 2001 From: Thushara-Piyasekara Date: Mon, 4 Mar 2024 09:10:08 +0530 Subject: [PATCH 7/7] Add tearDown function for pkgNode --- .../test/annotations/ExternalDependencyAnnotationTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java index 57957ef63af6..5aea3b61d5c0 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/ExternalDependencyAnnotationTest.java @@ -21,6 +21,7 @@ import org.ballerinalang.model.elements.AttachPoint; import org.ballerinalang.test.BCompileUtil; import org.ballerinalang.test.CompileResult; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.ballerinalang.compiler.tree.BLangFunction; @@ -75,5 +76,9 @@ public void testExternalDependencyAnnotOnTypeDefinitions() { List typeDefinitions = pkgNode.typeDefinitions; assertEquals(typeDefinitions.get(0).annAttachments.get(0).annotationName.value, "ExternalDependency"); } -} + @AfterClass + public void tearDown() { + pkgNode = null; + } +}