-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynFields, DynMethods code cleanup #10543
Conversation
6db2492
to
b5289b0
Compare
@@ -161,6 +161,8 @@ private BoundMethod(UnboundMethod method, Object receiver) { | |||
this.receiver = receiver; | |||
} | |||
|
|||
/** @deprecated since 1.6.0, will be removed in 1.7.0 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate please why these are being deprecated? It's not obvious for a reviewer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Dyn*
classs are copied from Parquet and contain more code than needed by Iceberg codebase. I assume these utilities were not meant to be API of the project and so any dead code here should be removed. Per revapi checks, removal requires prior deprecation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind having a few additional methods around. They come in a pair of {invoke, invokeChecked}
. It looks weird if they are sometime defined, and sometimes missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking is that any variant needed in the future is very easy to add when needed and doesn't necessitate keeping current-dead-code around. Removing dead code clears the picture and open eyes on further simplifications. Does this make sense? BTW recently, i was starring at a pretty complex class that was negatively impacted by some other changes only to eventually realize it's used only in its own tests and can simply be deleted. What a relief.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we should just remove the dead code. But I am also ok leaving it around if it helps something. let me know which direction you want this to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to either remove stuff or keep it there to keep the full picture. If we decide to remove this, I think we can clean it up even further. As part of #10542 we can mark invokeChecked
as deprecated there. Then we can just inline invokeChecked
in DynMethods
:
@SuppressWarnings("unchecked") | |
public <R> R invokeChecked(Object target, Object... args) throws Exception { | |
try { | |
if (argLength < 0) { | |
return (R) method.invoke(target, args); | |
} else { | |
return (R) method.invoke(target, Arrays.copyOfRange(args, 0, argLength)); | |
} | |
} catch (InvocationTargetException e) { | |
Throwables.propagateIfInstanceOf(e.getCause(), Exception.class); | |
Throwables.propagateIfInstanceOf(e.getCause(), RuntimeException.class); | |
throw Throwables.propagate(e.getCause()); | |
} | |
} |
Less is more!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure i follow. for now i just dropped deprecation of invokeChecked methods in this PR. My intuitive reaction to IDE warning about dead code such as unused method is to remove it, but clearly it's not as simple. Maybe we do this as a follow-up, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm trying to say is that we should mark this invokeChecked
as deprecated as well. Since that's only being used from invoke
. This way we can remove invokeChecked
completely from the public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. done!
Avoid a warning in an IDE.
b5289b0
to
8cf0678
Compare
8cf0678
to
06bad72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @findepi Thanks for cleaning this up 👍
No description provided.