Skip to content
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

AssistedInject needs class load bridging under OSGi #337

Closed
gissuebot opened this issue Jul 7, 2014 · 8 comments
Closed

AssistedInject needs class load bridging under OSGi #337

gissuebot opened this issue Jul 7, 2014 · 8 comments

Comments

@gissuebot
Copy link

From Rinsvind on February 15, 2009 08:25:01

AssistedInject implements the factory interfaces by building dynamic
proxies. Under OSGi this creates the same class loading problem as with the
proxies and interceptors that Guice itself generates. So we need the
classloader bridges implemented in com.google.inject.internal.BytecodeGen.
Luckily BytecodeGen is built more as a standalone utility and this makes it
dead simple to solve the problem. I am attaching a 2-liner patch that calls
BytecodeGen during proxy generation to obtain a bridge ClassLoader for the
new proxy.

This patch must be used with Stuart's fragments patch from issue #311 to
get a working assistedinject bundle.

Btw I tried to replace the java.lang.reflect.Proxy with the fancier
BytecodeGen.newEnhancer(). Here I hit a wall because AssistedInject is
build against both the guice-snapshot.jar that contains a JarJar-mangled
cglib and the cglib-snapshot.jar from lib\build. After some toying with the
ant scripts I gave up and settled for just BytecodeGen.getClassLoader().

Finally I propose that BytecodeGen eventually be moved to the spi package
so that all extensions that need to generate proxies can use it.

Attachment: gist
   assistedinject-classload.patch

Original issue: http://code.google.com/p/google-guice/issues/detail?id=337

@gissuebot
Copy link
Author

From mcculls on March 30, 2009 03:59:15

I'd like to get this resolved in Guice 2.1 if possible.

Labels: Type-Defect Milestone-Release2.1

@gissuebot
Copy link
Author

From rwallace1979 on April 15, 2009 21:33:03

There's a minor conflict with the previous patch and trunk.  Attaching an updated patch.

Attachment: gist
   assistedinject-classload.patch

@gissuebot
Copy link
Author

From limpbizkit on April 26, 2009 14:31:12

(No comment was entered for this change.)

Labels: Extension-AssistedInject Priority-Low

@gissuebot
Copy link
Author

From mcculls on October 30, 2009 21:02:50

Will make sure this patch is up-to-date as part of my general OSGi cleanup for 2.1

Status: Started
Owner: mcculls

@gissuebot
Copy link
Author

From mcculls on May 04, 2010 03:34:53

Description

This patch updates the newProxyInstance calls in AssistedInject to use the
classloader provided by the internal BytecodeGen utility class. The BytecodeGen class
returns a classloader based on the type being proxied that still works in
custom-classloading scenarios.

Owner: sberlin

Attachment: gist
   GUICE_ISSUE_337_20100504.patch

@gissuebot
Copy link
Author

From mcculls on May 04, 2010 03:41:40

NOTE: the patch assumes that the internal BytecodeGen class has been made public

Index: src/com/google/inject/internal/BytecodeGen.java
===================================================================
--- src/com/google/inject/internal/BytecodeGen.java     ( revision 1157 )
+++ src/com/google/inject/internal/BytecodeGen.java     (working copy)
@``@ -55,7 +55,7 @``@
  * @author mcculls@gmail.com (Stuart McCulloch)
  * @author jessewilson@google.com (Jesse Wilson)
  */
-final class BytecodeGen {
+public final class BytecodeGen {

   private static final Logger logger = Logger.getLogger(BytecodeGen.class.getName());

@gissuebot
Copy link
Author

From mcculls on May 04, 2010 04:27:44

(No comment was entered for this change.)

Labels: -Type-Defect Type-Patch

@gissuebot
Copy link
Author

From sberlin on May 09, 2010 05:52:27

fixed in r1158 .  thanks very much for the patch, Stuart!

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant