-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add a helper method to judge whether a given instance has been enhanced #1340
Conversation
Marker interfaces don't play well with modular systems like JPMS because the enhanced class needs to be able to access both the type it's enhancing and the marker interface, which is likely defined in a different classloader. This means you need to use a "bridge" classloader for the enhanced class which introduces a lot of extra complexity. The new enhancer code in #1298 deliberately avoids introducing Guice-specific types in the enhanced class, which keeps the classloading very simple. Introducing a Guice-specific marker interface here would undo this work and mean we'd need to bring back bridge class-loading. I'd also question what this marker interface would be used for - ie. why do clients need to know if the type has been enhanced or not, and why can't they look at the class name or hierarchy (Guice uses a naming convention for enhanced types which makes this relatively straightforward.) An alternative solution would be to introduce a static helper that returned whether a given class or instance has been enhanced. This could use the naming convention as described above to decide and would avoid the need to introduce a dependency back to Guice from the enhanced type. |
mcculls thank you. I think you are right. I added such a static helper method in Guice.java and this method can returns whether the given instance has been enhanced. In addition, I added a testing method in BytecodeGenTest.java |
…hanced (and its testing method)
I wonder if we might add |
Solve issue #187
I add a marker interface in the file bytecodeGen.java
Each time a new Enhanced class is generated, it also generate a instance with marker interface.