Library compiler java package error

15 views (last 30 days)
CHV on 7 Jul 2021
Commented: CHV on 8 Jul 2021
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(
at com.mathworks.mvm.exec.FutureResult.getInternal(
at com.mathworks.mvm.exec.FutureFevalResult.getInternal(
at com.mathworks.mvm.exec.FutureResult.get(
at com.mathworks.toolbox.compiler_examples.generation.ExampleValidator.validateExample(
at com.mathworks.toolbox.compiler.plugin.PackageCommand$3.iterate(
at com.mathworks.project.impl.plugin.XmlReaderImpl.loop(
at com.mathworks.toolbox.compiler.plugin.PackageCommand.packageSamples(
at com.mathworks.toolbox.compiler.plugin.PackageCommand.execute(
at com.mathworks.project.impl.engine.DeploymentEngine.executeScript(
at com.mathworks.project.impl.engine.DeploymentEngine.access$000(
at com.mathworks.project.impl.engine.DeploymentEngine$
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

Answers (1)

Kojiro Saito
Kojiro Saito on 8 Jul 2021
Edited: Kojiro Saito on 8 Jul 2021
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;
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.
Remove or comment out "clear all" in your sample script. In the above example, addmatrixWithClearSample2.m should be the following.
%clear all; % Comment out
in1 = 0; % Initialize in1 here
in2 = 0; % Initialize in2 here
out = addmatrix(in1, in2);
CHV on 8 Jul 2021
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

Sign in to comment.


Find more on Java Package Integration in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!