Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Jul 19, 2023

This moves usage of @Value.Immutable on all Actions Result classes to iceberg-core by maintaining the original naming of the classes and builders. Moving this will not cause breaking API changes for consuming users, because most (all?) users will have a dependency to iceberg-core when using iceberg-api.

The reason for moving this from iceberg-api to iceberg-core is because we don't want to make generated Builders from @Value.Immutable part of the API module and the respective API guarantees.

View-specific immutable classes are moved as part of #7992.

Once both PRs are merged, I'll add a follow-up and mention in the docs that @Value.Immutable usage is discouraged on iceberg-api and will also remove the immutable dependency for that project

@zinking
Copy link
Contributor

zinking commented Jul 20, 2023

+1, make sense. API module should only include interface contracts and ideally zero dependency on anything else.

@nastra nastra requested a review from rdblue July 20, 2023 12:27
@nastra nastra force-pushed the move-immutables-to-core branch from 4f0d49d to 5eb28f8 Compare July 26, 2023 06:20
// any Immutable-specific class to the classpath
@SuppressWarnings("ImmutablesStyle")
@Value.Style(typeImmutableEnclosing = "ImmutableSnapshotTable")
public interface BaseSnapshotTable extends SnapshotTable {
Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot to check this in the last PR, but I really don't like that this is a public interface that completely duplicates the SnapshotTable interface from API. Is it possible to make this package-private? Or is that a limitation of Immutables?

Copy link
Contributor Author

@nastra nastra Jul 27, 2023

Choose a reason for hiding this comment

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

yes that's absolutely possible. Just worth mentioning that the generated class ImmutableSnapshotTable will have the same visibility, unless we add visibility = Value.Style.ImplementationVisibility.PUBLIC to make the generated class public. Did you want to only make this one package-private?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, definitely. We want to make sure that people don't see or use these because they aren't real interfaces. They're just artifacts of using Immutables.

Can you also fix the other PR if those were public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it turns out adding visibility = Value.Style.ImplementationVisibility.PUBLIC will cause warnings for consuming clients (same issue as #291) and the suggested workaround isn't really feasible for us.
I've opened immutables/immutables#1474 to fix this in Immutables and verified that consuming clients don't see the below warning with my proposed fix

warning: unknown enum constant ImplementationVisibility.PUBLIC
  reason: class file for org.immutables.value.Value$Style$ImplementationVisibility not found

Should we go ahead and merge this PR for now to unblock other work and I'll follow up and make those classes package-private but their generated classes public once the issue is fixed upstream?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about just copying the Immutable output classes into src? Then we don't need the duplicate interfaces or codegen not doing what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've looked closer into this and I don't think this is actually a direct issue of using Immutables per-se, but rather something with javac. The generated class looks identical with/without the ImplementationVisibility and the javac warning won't cause any issues for consuming clients.
I went ahead an made all relevant interfaces package-protected and specified the visibility of the generated Class/Builder.

@nastra nastra force-pushed the move-immutables-to-core branch from 4193b7d to f7ef545 Compare July 31, 2023 13:11
@rdblue rdblue merged commit 6bdb841 into apache:master Jul 31, 2023
@rdblue
Copy link
Contributor

rdblue commented Jul 31, 2023

Thanks, @nastra! I'm glad you were able to solve the immutables problem.

@nastra nastra deleted the move-immutables-to-core branch August 1, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants