ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.58k stars 737 forks source link

[Bug]: Problem on error message when a method is used wrongly without a receiver. #41414

Closed NirashaSewwandi closed 8 months ago

NirashaSewwandi commented 1 year ago

Description

ERROR:

[2023-09-19 21:09:58,198] SEVERE {b7a.log.crash} - Index 1 out of bounds for length 1 java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at org.wso2.ballerinalang.compiler.bir.codegen.interop.JMethodResolver.isAcceptingBundledParams(JMethodResolver.java:200) at org.wso2.ballerinalang.compiler.bir.codegen.interop.JMethodResolver.resolveByParamCount(JMethodResolver.java:159) at org.wso2.ballerinalang.compiler.bir.codegen.interop.JMethodResolver.resolve(JMethodResolver.java:130) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.validateAndGetJMethod(InteropValidator.java:203) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.createJInteropFunction(InteropValidator.java:223) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.getBirFunction(InteropValidator.java:210) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.validateModuleFunctions(InteropValidator.java:149) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.validateFunctions(InteropValidator.java:124) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.validateModulePackages(InteropValidator.java:96) at org.wso2.ballerinalang.compiler.bir.codegen.interop.InteropValidator.validate(InteropValidator.java:76) at io.ballerina.projects.JBallerinaBackend.performCodeGen(JBallerinaBackend.java:317) at io.ballerina.projects.ModuleContext.generateCodeInternal(ModuleContext.java:480) at io.ballerina.projects.ModuleCompilationState$4.generatePlatformSpecificCode(ModuleCompilationState.java:132) at io.ballerina.projects.ModuleContext.generatePlatformSpecificCode(ModuleContext.java:387) at io.ballerina.projects.JBallerinaBackend.performCodeGen(JBallerinaBackend.java:173) at io.ballerina.projects.JBallerinaBackend.(JBallerinaBackend.java:142) at io.ballerina.projects.JBallerinaBackend.lambda$from$0(JBallerinaBackend.java:120) at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134) at io.ballerina.projects.PackageCompilation.getCompilerBackend(PackageCompilation.java:172) at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:119) at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:201) at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40) at io.ballerina.cli.cmd.BuildCommand.execute(BuildCommand.java:288) at java.base/java.util.Optional.ifPresent(Optional.java:183) at io.ballerina.cli.launcher.Main.main(Main.java:56)

Steps to Reproduce

Run bal build on following bal project

apachePOI.zip

It will get the above error. Problem here is the error message.

To resolve the error : Direct to modules/org.apache.poi/org.apache.poi.bal and change the read() method as follows

public isolated function read(handle receiver) returns int|error = @java:Method`
{
    name: "read",
    'class: "org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream"

} external;

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

github-actions[bot] commented 8 months ago

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.