Skip to main content
Code Review

Return to Question

deleted 15 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Generated Code Proxycode proxy

In my library Transfuse I use a code generator to build a handful of classes that look up resources. Each of these look up classes are proxied by a static utility class so they may be referenced before the generated class is built. For instance, the ParcelsParcels class can be used to wrap an object with a generated ParcelableParcelable class:

ParcelsParcels proxies a generated class called Transfuse$Parcels.

ParcelsParcels:

My question is the following: isIs this technique of loading the generated class using the static initialization block optimal? As you can see, if the class is not found (not generated possibly) then the ParcelRepository instance ends up being nullnull and wrap() would always return nullnull. Should wrap() throw a runtime exception if an instance is not found instead?

Generated Code Proxy

In my library Transfuse I use a code generator to build a handful of classes that look up resources. Each of these look up classes are proxied by a static utility class so they may be referenced before the generated class is built. For instance, the Parcels class can be used to wrap an object with a generated Parcelable class:

Parcels proxies a generated class called Transfuse$Parcels.

Parcels:

My question is the following: is this technique of loading the generated class using the static initialization block optimal? As you can see, if the class is not found (not generated possibly) then the ParcelRepository instance ends up being null and wrap() would always return null. Should wrap() throw a runtime exception if instance is not found instead?

Generated code proxy

In my library Transfuse I use a code generator to build a handful of classes that look up resources. Each of these look up classes are proxied by a static utility class so they may be referenced before the generated class is built. For instance, the Parcels class can be used to wrap an object with a generated Parcelable class:

Parcels proxies a generated class called Transfuse$Parcels.

Parcels:

Is this technique of loading the generated class using the static initialization block optimal? As you can see, if the class is not found (not generated possibly) then the ParcelRepository instance ends up being null and wrap() would always return null. Should wrap() throw a runtime exception if an instance is not found instead?

deleted 22 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Parcels proxies a generated class called Transfuse$ParcelsTransfuse$Parcels.

Transfuse$ParcelsTransfuse$Parcels:

My question is the following: is this technique of loading the generated class using the static initialization block optimal? As you can see, if the class is not found (not generated possibly) then the ParcelRepositoryParcelRepository instance ends up being null and wrap()wrap() would always return null. Should wrap()wrap() throw a runtime exception if instance is not found instead?

Any guidance is appreciated.

Parcels proxies a generated class called Transfuse$Parcels.

Transfuse$Parcels:

My question is the following: is this technique of loading the generated class using the static initialization block optimal? As you can see, if the class is not found (not generated possibly) then the ParcelRepository instance ends up being null and wrap() would always return null. Should wrap() throw a runtime exception if instance is not found instead?

Any guidance is appreciated.

Parcels proxies a generated class called Transfuse$Parcels.

Transfuse$Parcels:

My question is the following: is this technique of loading the generated class using the static initialization block optimal? As you can see, if the class is not found (not generated possibly) then the ParcelRepository instance ends up being null and wrap() would always return null. Should wrap() throw a runtime exception if instance is not found instead?

edited tags
Link
200_success
  • 145.5k
  • 22
  • 190
  • 479
Notice removed Draw attention by Community Bot
Bounty Ended with no winning answer by Community Bot
Tweeted twitter.com/#!/StackCodeReview/status/294532016890855424
Notice added Draw attention by John Ericksen
Bounty Started worth 50 reputation by John Ericksen
added 134 characters in body
Source Link
Loading
Source Link
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /