Library compiler java package error

10 ビュー (過去 30 日間)
CHV
CHV 2021 年 7 月 7 日
コメント済み: CHV 2021 年 7 月 8 日
I am trying to use the library compiler to generate a java package for matlab functions. And I select all the functions with an existing sample.
But I am facing the below error and no files are generated in xxxx/for_redistribution_files_only\samples.
com.mathworks.mvm.exec.MvmExecutionException: compiler.internal.ExampleParser.getArgumentValidation
at com.mathworks.mvm.exec.NativeFutureResult.nativeGet(Native Method)
at com.mathworks.mvm.exec.NativeFutureResult.get(NativeFutureResult.java:62)
at com.mathworks.mvm.exec.FutureResult.getInternal(FutureResult.java:413)
at com.mathworks.mvm.exec.FutureFevalResult.getInternal(FutureFevalResult.java:49)
at com.mathworks.mvm.exec.FutureResult.get(FutureResult.java:263)
at com.mathworks.toolbox.compiler_examples.generation.ExampleValidator.validateExample(ExampleValidator.java:41)
at com.mathworks.toolbox.compiler.plugin.PackageCommand$3.iterate(PackageCommand.java:416)
at com.mathworks.project.impl.plugin.XmlReaderImpl.loop(XmlReaderImpl.java:232)
at com.mathworks.toolbox.compiler.plugin.PackageCommand.packageSamples(PackageCommand.java:409)
at com.mathworks.toolbox.compiler.plugin.PackageCommand.execute(PackageCommand.java:676)
at com.mathworks.project.impl.engine.DeploymentEngine.executeScript(DeploymentEngine.java:373)
at com.mathworks.project.impl.engine.DeploymentEngine.access$000(DeploymentEngine.java:44)
at com.mathworks.project.impl.engine.DeploymentEngine$2.run(DeploymentEngine.java:289)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.mathworks.mvm.exec.MvmRuntimeException: Reference to a cleared variable this.
Error in ==> C:\Program Files\MATLAB\R2020b\toolbox\compiler_sdk\java\+compiler\+internal\ExampleParser.p>ExampleParser.getVariables at 0
Error in ==> C:\Program Files\MATLAB\R2020b\toolbox\compiler_sdk\java\+compiler\+internal\ExampleParser.p>ExampleParser.getArgumentValidation at 0

回答 (1 件)

Kojiro Saito
Kojiro Saito 2021 年 7 月 8 日
編集済み: Kojiro Saito 2021 年 7 月 8 日
I can reproduce this issue if sample m script contains clear all.
Reproduction Step
addmatrix.m (to be compiled as Java package)
function out = addmatrix(in1, in2)
out = in1 + in2;
end
addmatrixWithClearSample2.m (sample m file which calls addmatrix)
clear all;
in1 = 0; % Initialize in1 here
in2 = 0; % Initialize in2 here
out = addmatrix(in1, in2);
Add addmatrixWithClearSample2.m from "Add Existing Sample" in Samples panel of Library Compiler window.
When packaging, we'll get "Caused by: com.mathworks.mvm.exec.MvmRuntimeException: Reference to a cleared variable this." error as you provided.
Solution
Remove or comment out "clear all" in your sample script. In the above example, addmatrixWithClearSample2.m should be the following.
addmatrixWithClearSample2.m
%clear all; % Comment out
in1 = 0; % Initialize in1 here
in2 = 0; % Initialize in2 here
out = addmatrix(in1, in2);
  2 件のコメント
CHV
CHV 2021 年 7 月 8 日
Thanks for the solution. After removing the clear all I am not facing this issue.
CHV
CHV 2021 年 7 月 8 日
I am requesting you to Can you please have a look in the below issue and provide me the solution for this one also.
Thanks in advance

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeJava Package Integration についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by