Library compiler java package error

조회 수: 7 (최근 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 CenterFile Exchange에서 Java Package Integration에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by