Skip to content

TRestTools: replace TClass::kIsEmulation, removed in ROOT 6.30 - #576

Merged
diazovejas merged 1 commit into
masterfrom
jdo_root630_emulated_check
Nov 16, 2026
Merged

diazovejas merged 1 commit into
masterfrom
jdo_root630_emulated_check

Conversation

@diazovejas

@diazovejas diazovejas commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

diazovejas Ok: 1 Powered by Pull Request Badge

TClass::kIsEmulation was deprecated and finally removed in ROOT 6.30.
This PR uses cl->GetState() <= TClass::kEmulated instead.

Context: for the upcoming release the plan is to move the installer from ROOT 6.26.10 to ROOT 6.38.06, so master would not compile.

Tested: full build and restRoot on macOS with ROOT 6.40.04 (Homebrew).

@Vindaar could you review it? In particular, confirm that <= kEmulated matches the
emulated-class path you intended in LoadOnDiskSchemaRules before we change the installer default.

@Vindaar Vindaar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't realize you pinged me on this. Lately not been paying that much attention to github.

Yes, the PR is fine as is. It slightly changes the behavior, but not in a way that causes a problem. The new check also covers classes for which ROOT has even less information than in the kEmulated state. For this particular preservation helper, that is appropriate: a lack of class information should not prevent us from preserving an existing rule!
Note: kIsEmulation was deprecated back in 2014, before ROOT 6.00, and finally removed in 6.38 iiuc, not that it matters.

For completeness, let me quickly expand on what LoadOnDiskSchemaRules even is for and what the particular line this PR changes actually intends to do.

This all comes down to an asymmetry in the ROOT I/O logic. ROOT 6.26 and 6.38 (and presumably all in between as well) explicitly ignore schema rules when opening a file (0, note the #if 0). Why? I have no idea. At the same time though, when rebuilding the metadata of a file 1 only the in-memory schema rules associated with the relevant classes are used. The existing on-disk rules are not copied over. Consequently, they can be lost unless they are already registered in memory, for example through a loaded dictionary or explicit registration.

LoadOnDiskSchemaRules then is used in order to make sure all schema rules that exist on disk in the file are actually attached to the corresponding in-memory TClass objects. The input to the function is a snapshot of the file's schema metadata, including its stored rules for potentially multiple classes. The code then looks for the TClass known by ROOT corresponding to each existing schema rule and makes sure the rule is attached to the class. The entire point is just to make sure that ROOT knows about this rule, which we know was stored in the file and names that class as its target!

Note that in practice this does not often lead to problems for two main reasons:

  • schema rules are not needed that often. Many schema changes are handled by ROOT automatically
  • applications commonly load libraries containing the dictionaries for their classes. These are autogenerated from the source code. E.g. when working with REST the REST libraries are normally loaded, which include descriptions of the memory layouts etc. of all the classes, including possible schema rules written via #pragma read in the source code. Those rules are therefore already registered in memory, independently of the copies stored in the file. This only covers the rules supplied by the loaded dictionary, however and not necessarily every rule stored in the file.

Issues can happen when for example opening a REST ROOT file in a ROOT process in which REST libraries are not loaded and performing a write operation that triggers a rebuild of the schema metadata. This asymmetry can cause loss of schema-rule metadata in that scenario.

To get back to the PR: the enum used here with the new check GetState() <= kEmulated then encompasses kNoInfo, kForwardDeclared and kEmulated. kNoInfo means ROOT has no information about the class. kForwardDeclared means ROOT simply knows it exists, but nothing else. And kEmulated means ROOT knows about the class from TStreamerInfo, but not from a complete C++ definition. As stated earlier though, we know already that these rules were stored in the file for that target class. As a result we do not need a complete class definition merely to preserve them. This does not prove that the rules are valid, but it means that insufficient information to validate their target members is not a reason to discard them. We simply need to ensure ROOT retains these rules when rewriting the metadata.

I hope this helps somewhat to anyone reading this PR.

@diazovejas
diazovejas merged commit 4f7a91b into master Nov 16, 2026
64 checks passed
@diazovejas
diazovejas deleted the jdo_root630_emulated_check branch November 16, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants