Skip to content

Conversation

@dyrpsf
Copy link
Contributor

@dyrpsf dyrpsf commented Jan 13, 2026

Summary

This PR fixes sbmlteam/jsbml#252.

Previously, the GeneProduct(GeneProduct nsb) copy constructor only called the
super-constructor and did not copy the label (required) or associatedSpecies
fields. Since clone() is implemented as:

@Override
public GeneProduct clone() {
  return new GeneProduct(this);
}

cloning a GeneProduct would result in a cloned instance missing these fields,
potentially producing invalid SBML.

The copy constructor is now:

public GeneProduct(GeneProduct nsb) {
  super(nsb);

  if (nsb.isSetLabel()) {
    setLabel(nsb.getLabel());
  }

  if (nsb.isSetAssociatedSpecies()) {
    setAssociatedSpecies(nsb.getAssociatedSpecies());
  }
}

so that both label and associatedSpecies are preserved when cloning.

Verification
Local compilation with Maven (core + fbc) succeeds using Java 11.
Cloning a GeneProduct now yields an equal instance with the same label
and associatedSpecies.

Fixes #252

@dyrpsf
Copy link
Contributor Author

dyrpsf commented Jan 24, 2026

Hi, this PR was automatically closed because I had to reset and clean up my branches while reverting recent changes.
I’ll reopen a fresh PR once the work is re-applied cleanly.
Thanks!

@draeger draeger self-assigned this Jan 24, 2026
@dyrpsf dyrpsf reopened this Jan 24, 2026
@dyrpsf dyrpsf closed this Jan 24, 2026
@dyrpsf dyrpsf deleted the geneproduct-clone-label branch January 24, 2026 17:38
@dyrpsf dyrpsf reopened this Jan 24, 2026
@dyrpsf
Copy link
Contributor Author

dyrpsf commented Jan 24, 2026

Hi everyone,

Just a quick update: everything is now set and all issues have been resolved. The changes have been reapplied cleanly, and this PR, as well as all other PRs I previously mentioned with problems, are now in good shape. Feel free to review at your convenience.

Thanks for your patience!

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.

Cloning of GeneProduct may create invalid SBML because of missing required attribute label

2 participants