-
Notifications
You must be signed in to change notification settings - Fork 12
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
Remove reflections #117
Remove reflections #117
Conversation
Hi @hoangmaihuy! Thank you so much for your contribution! That's a very clever change. I didn't expect it's that straightforward to drop reflections 😄 |
I found some issues while decoding ADTs. I will figure it out on my own 😃 |
@vitaliihonta Thank you a lot for this great work, glad I can help! 😄 |
TODOs
|
@vitaliihonta Workaround for private def getClassCompanion[T](
valueClass: Class[T]
): GeneratedMessageCompanion[GeneratedMessage] = {
val companionClass = Class.forName(valueClass.getName + "$")
companionClass
.getDeclaredField(scalaModuleField)
.get(null)
.asInstanceOf[GeneratedMessageCompanion[GeneratedMessage]]
}
private def getCompanion[T](
typeUrl: String,
valueClass: Class[T]
): GeneratedMessageCompanion[GeneratedMessage] = {
println(s"typeUrl = $typeUrl")
println(s"valueClass = ${valueClass.getName}")
if (valueClass.isInterface && valueClass.getInterfaces.contains(classOf[GeneratedSealedOneof])) {
val subClassType = typeUrl.split("\\.").last
val subClassName = valueClass.getName.replace(valueClass.getSimpleName, subClassType)
println(s"subClassName = ${subClassName}")
getClassCompanion(Class.forName(subClassName))
} else {
getClassCompanion(valueClass)
}
} |
# Conflicts: # integration-tests/src/test/scala/zio/temporal/protobuf/internal/ProtoFileObjectAutoLoaderSpec.scala
Hey @hoangmaihuy, could you merge my updates from #120 into your branch? I cannot push my changes to your fork directly, but I want to keep you in the commit history 😃 Your solution works perfectly! I just had to adapt it for some internal corner cases |
@vitaliihonta I've merged #120 into this branch 😄 |
Codecov Report
@@ Coverage Diff @@
## main #117 +/- ##
==========================================
- Coverage 39.05% 38.43% -0.63%
==========================================
Files 116 115 -1
Lines 4127 4046 -81
==========================================
- Hits 1612 1555 -57
+ Misses 2515 2491 -24
|
@hoangmaihuy, thank you so much for your contribution 🙌 |
Changes being made
Remove
reflections
from dependencies. I've made changes in two places:ClassTagUtils
: Simply replacereflections
usage with Java's reflection methodsScalapbPayloadConverter
:reflections
is being used for scanning Scalapb's companion objects, but instead we can get companion object fromvalueClass
.Additional context
reflections is not under active development and maintenance, and it has serveral issues on newer JDKs, please see ronmamo/reflections#440 and ronmamo/reflections#377 for example.