Skip to content

Conversation

@dyrpsf
Copy link

@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

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

1 participant