The code for handling enum types in Group.java is
incorrect. When creating a new enum type, it is appropriate to
search only the current group for a conflicting name and this is
what the current code does. But when an enum typed variable
searches for the matching enum type, it must search not only the
current group but all parent groups and the current code does
not do that.
The fix consists of two similar parts.
Modify Group.findEnumeration to take an extra boolean parameter
to control if search is this group only or to search up the group's parents.
Modify Group.Builder.findEnumTypedef to act like part 1 but to search
the sequence of parent Group.Builder instances.
As a consequence, this PR modifies a number of other files to
adapt to the modified signatures.
Note
This same problem appears to affect the opaque type also, but
fixing that may be a bit more difficult because CDM appears to
convert opaque types to byte typess.
It turns out that I missed the error in the code in H5headerNew that
attempts to match an enum typed variable with the proper enumeration
type declaration.
The problem and fix (as described by a comment in H5headerNew)
is a bit of a hack. It should be fixed in H5Object.read().
Unfortunately, information is not being passed down so that
the proper fix can be applied early in the HDF5->CDM translation.
Fixing this would affect a lot of function signatures.
Also modified TestEnumTypedef.java to test two cases:
the actual enum type def is in the same group as the variable that uses it.
the actual enum type def is in a parent group of the variable that uses it
Misc. Other Changes
Suppress printing of _NCProperties to simplify text-based comparison testing.
Addendum 2 (12/19/2022)
NetcdfFile.java: convert to use H5iospNew (needed by TestH5iosp.java)
H5headerNew.java: provide get function for accessing the btree (needed by TestDataBTree.java)
H5iospNew.java: make getRandomAccessFile() method public (needed by tests)
CompareNetcdf2.java: Add a constructor to specify if attribute name comparison should ignore case or not. It turns out that some tests require case sensitive name matching. Specifically TestCoordSysCompare.java and TestN3iospCompare.java
Addendum 3 (2/25/2023)
Make additional changes to fix Jenkins failures.
Revert Group.attributes()
Revert the use of H5iospNew in NetcdfFile.
Add to Group a method that looks for a matching enumeration purely structurally, as opposed to name matching. This corresponds to the same method in Group Builder.
Rebuild the EnumTypedef search algorithm in H5headerNew and H5header to handle cases in Jenins only enum tests.
Revert various calls to Group.findEnumeration().
Add some test case data: ref_anon_enum.h5 and test_enum_type.nc
Convert TestEnumTypedef to JUNIT.parameter form.
Revert TestH5iosp.
The URL used in TestSequence is no longer valid, so change to an equivalent url on the remotetest server.
Description of Changes
re: Issue https://github.com/Unidata/netcdf-java/issues/126
The code for handling enum types in Group.java is incorrect. When creating a new enum type, it is appropriate to search only the current group for a conflicting name and this is what the current code does. But when an enum typed variable searches for the matching enum type, it must search not only the current group but all parent groups and the current code does not do that.
The fix consists of two similar parts.
As a consequence, this PR modifies a number of other files to adapt to the modified signatures.
Note
This same problem appears to affect the opaque type also, but fixing that may be a bit more difficult because CDM appears to convert opaque types to byte typess.
PR Checklist
Addendum 1
It turns out that I missed the error in the code in H5headerNew that attempts to match an enum typed variable with the proper enumeration type declaration.
The problem and fix (as described by a comment in H5headerNew) is a bit of a hack. It should be fixed in H5Object.read(). Unfortunately, information is not being passed down so that the proper fix can be applied early in the HDF5->CDM translation. Fixing this would affect a lot of function signatures.
Also modified TestEnumTypedef.java to test two cases:
Misc. Other Changes
Addendum 2 (12/19/2022)
Addendum 3 (2/25/2023)
Make additional changes to fix Jenkins failures.