Skip to content

Warning: type does not exist in workspace; reconstructing #390

@Amuri44

Description

@Amuri44

I was using the below code to create .jld2 file containing an instance Sim of structure Simulation

include("./SimulationStructure.jl");
function appFunction()
Sim = Simulation();
io = open("$(@__DIR__)/generatedElements.jld2", "w")
close(io)
save("$(@__DIR__)/generatedElements.jld2", "Sim", Sim, "Simulation", Simulation)
end
appFunction();

in which SimulationStructure.jl:

using base
export Simulation 
Base.@kwdef mutable struct Simulation 
    dt::Float64 = 1e-6
    tmax::Float64 = 32*1e-3
end

Then, I was reading the created .jld2 by the below code called readFile.jl. and It was working without any warning, in which typeof Sim is Simulation

include("./SimulationStructure.jl");
Sim, Simulation = load("$(@__DIR__)/generatedElements.jld2", "Sim", "Simulation");
julia> typeof(Sim)
Simulation

Now, I have built executable for appFunction() as below and it works fine to generate the .jld2 file.

module readApp

Base.@ccallable function julia_main()::Cint
    try
        appFunction()
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
    return 0
end

Base.@kwdef mutable struct Simulation 
  dt::Float64 = 1e-6
  tmax::Float64 = 32*1e-3
end

function appFunction()
Sim = Simulation();
save("$(@__DIR__)/generatedElements.jld2", "Sim", Sim, "Simulation", Simulation)
end
end

However, calling readFile.jl to read the generated .jld2 gives this warning and typeof Sim is Simulation

┌ Warning: type readApp.Simulation does not exist in workspace; reconstructing
└ @ JLD2 C:\Users\amroa\.julia\packages\JLD2\k9Gt0\src\data\reconstructing_datatypes.jl:461
julia> typeof(Sim)
JLD2.ReconstructedTypes.var"##readApp.Simulation#292"
julia> Simulation
JLD2.UnknownType{String}("testtest.Simulation", #undef)

How can I get ride of the warning and fix the typeof(Sim) to be of Simula JLD2 to be of Simulation?tion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions