Commit Graph
24 Commits
Author SHA1 Message Date
Guice TeamandGuice Team dd873be400 Remove AOP build variant.
Changes include:

- skip tests that are testing bytecode generation enabled behaviors
- make line number and source file name information available even when bytecode generation is disabled since it does not use bytecode generation and makes testing easier (some tests rely on the information being available)
- update maven pom files to stop producing a no-aop version of Guice
- added test profile to execute tests with bytecode generation disabled

PiperOrigin-RevId: 336306344
2020-10-09 09:23:54 -07:00
Guice TeamandGuice Team b7cadc1cfa Migrate several tests to junit4 so that tests that rely on AOP can be skipped using Assume.assumeTrue.
PiperOrigin-RevId: 335755255
2020-10-06 17:18:53 -07:00
Stuart McCullochandkevinb9n 85e30beafe Import https://github.com/google/guice/pull/1298
Replace CGLIB with custom code to generate "enhancers" and "fast-classes".

Some user visible changes from using cglib:
- intercepted method that has a return type of int but returns null from the interceptor will no longer be automatically converted to 0, instead a NullPointerException will be thrown.
- Scope implementation can no longer check for circular proxy instance using CircularDependencyProxy marker class, instead should use Scopes.isCircularProxy
- Depending on which custom class loading option is used, Guice enhanced class may no longer be mockable/spyable
- Generated class name is slightly longer.

Closes #1298

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=320433559
2020-07-10 08:43:31 -07:00
samebandRon Shapiro 37255a24d9 Refactor code to use java8-isms.
Generated with refaster, with some manual touch-ups afterwards.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=238042288
2019-04-08 09:56:03 -04:00
lukesandRon Shapiro dcf7bdacc2 remove unnecessary explicit type parameters now that we are on java7
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145716288
2017-03-21 15:28:23 -04:00
lukesandSam Berlin 34e7c5d715 Run google-java-format on all Guice code.
configure a presubmit to ensure that it stays formatted.

Highlights include:
* simplified import order
* method annotations are now consistently defined on the preceding line
* javadoc reformatted to 100 chars column width

One test that contained line numbers in error messages had to be modified and
the formatter didn't like some of the more complicated preprocessor directives
(MOE and AOP).

To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132718493
2016-09-13 11:47:18 -04:00
lukesandSam Berlin 713c06cce9 Fix issues reported by errorprone
99% of this is adding missing @Override annotations, in the long tail we also have

* insert missing calls to Assert.fail() in tests that are testing exception behavior
* rewrite a few cases of Foo.class.instanceof(c) to c instanceof Foo
* rewrite Class.newInstance - > Class.getConstructor().newInstance() which doesn't break checked exception checking.
* adding @javax.inject.Inject annotations to methods that override methods annotated with @javax.inject.Inject

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131839622
2016-09-07 17:45:54 -04:00
lukesandSam Berlin 3afe00c4b4 Upgrade cglib to 3.2.
Update guice to depend on cglib 3.2.

Also, remove some unnecessary resources from the cglib jar.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=108146665
2016-01-06 15:19:42 -05:00
Sam Berlin c00df28be8 Automated code cleanups by internal tool.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69390543
2014-07-01 17:06:55 -04:00
Sam Berlin e91540ea9c Fixes issue 652. Allow method interceptors to capture the method & call it later from a
different context.  Patch by Tavian Barnes, thanks Tavian!
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=58040591
2013-12-11 18:45:14 -05:00
Sam Berlin 35023b810b Fix issue 779 -- deduplicate listeners & interceptors. Using a slightly modified patch from Tavian Barnes, thanks Tavian!
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=57798796
2013-12-06 17:34:24 -05:00
Sam Berlin 2823a381af Fix issue 643 using a slightly modified version of the patch provided by
Stuart.

Revision created by MOE tool push_codebase.
MOE_MIGRATION=4270
2012-02-26 21:24:52 -05:00
Sam Berlin 88ee52dec9 Fix issue 670, keep values from MapBinder & Multibinder distinct.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=4268
2012-02-26 21:22:30 -05:00
Sam Berlin 1c9b92a5d8 Fix issue 643 using a slightly modified version of the patch provided by
Stuart.
2012-01-21 12:55:00 -05:00
sberlin b7a02b02d8 * Remove unused imports
* Sort imports
* Convert tabs to spaces
* Fix the ant no_aop build


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2532


git-svn-id: https://google-guice.googlecode.com/svn/trunk@1572 d779f126-a31b-0410-b53b-1d3aecad763e
2011-07-08 00:34:16 +00:00
sberlin d9c913acca switch Guice from manually repackaging Guava to depending on Guava. it's still jarjar'd right now, which is causing a ~400k increase in guice-snapshot.jar. next step is to switch to ProGuard to remove the unnecessary code and cut it back down (even further?!). this will let people build from Guice source and depend directly on Guava code without having to worry about hiding internal/util.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1558 d779f126-a31b-0410-b53b-1d3aecad763e
2011-06-26 21:02:54 +00:00
sberlin be2505a424 specify that interceptors are called in the order they are listed in bindInterceptor(Matcher, Matcher, Interceptor...). add a test that guarantees it.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1542 d779f126-a31b-0410-b53b-1d3aecad763e
2011-04-21 18:17:15 +00:00
sberlin d4ec8b091b update to asm-3.3.1, update to new cglib that fixes a bug with bridge methods, add test that verifies the fix works. (previously it worked within Eclipse but not javac because eclipse's compiler wrote out bridge methods differently.)
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1540 d779f126-a31b-0410-b53b-1d3aecad763e
2011-04-20 16:57:24 +00:00
sberlin 1e5fc1daab fix typo, make test not loop forever.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1510 d779f126-a31b-0410-b53b-1d3aecad763e
2011-02-28 17:49:54 +00:00
sberlin 6e4e4973a8 update stack trace pruning (for AOP-internal methods & generated methods) to include causes.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1509 d779f126-a31b-0410-b53b-1d3aecad763e
2011-02-28 15:08:01 +00:00
sberlin 82d0fdbec0 rework method interception so that methods that aren't intercepted don't go through cglib, reducing the number of stack frames in most method calls. this has a slight side effect that additional proxy classes are generated for a single class if (and only if) the intercepted methods change. if the intercepted methods remain the same, then the proxy classes will continue to be shared (so things like assistedinject will not blow up the heap).
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1482 d779f126-a31b-0410-b53b-1d3aecad763e
2011-01-18 19:41:12 +00:00
limpbizkit@gmail.com e0f541287d Remove AOP boilerplate from user visible stack traces.
We received complaints because AOP stack traces are difficult to follow. This removes almost everything. The weird thing about this change is that the stack traces contain gaps. Anyone tracing through a stack trace should recognize that proceed() or invoke() means that AOP is in play.

The stack trace of a method that was subject to two interceptors used to look like this:

java.lang.Exception: kaboom!
	at com.publicobject.Interceptable.explode(Interceptable.java:203)
	at com.publicobject.Interceptable$$EnhancerByGuice$$5ffccef9.CGLIB$explode$2(<generated>)
	at com.publicobject.Interceptable$$EnhancerByGuice$$5ffccef9$$FastClassByGuice$$20c8faff.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:72)
	at com.publicobject.InterceptorB.invoke(InterceptorB.java:57)
	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:72)
	at com.publicobject.InterceptorA.invoke(InterceptorA.java:50)
	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:72)
	at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:52)
	at com.publicobject.MyTest$Interceptable$$EnhancerByGuice$$5ffccef9.explode(<generated>)
	at com.publicobject.MyTest.testInterceptedMethodThrows(MyTest.java:181)

Now it looks like this:

java.lang.Exception: kaboom!
	at com.publicobject.Interceptable.explode(Interceptable.java:203)
	at com.publicobject.InterceptorB.invoke(InterceptorB.java:57)
	at com.publicobject.InterceptorA.invoke(InterceptorA.java:50)
	at com.publicobject.MyTest.testInterceptedMethodThrows(MyTest.java:181)


git-svn-id: https://google-guice.googlecode.com/svn/trunk@1481 d779f126-a31b-0410-b53b-1d3aecad763e
2011-01-15 07:06:25 +00:00
sberlin b02627d4f5 issue 407 -- better error messaging for failed interception. previously exploded with a ComputationException, now uses a ConfigurationException with a good msg.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1319 d779f126-a31b-0410-b53b-1d3aecad763e
2010-10-25 04:56:00 +00:00
mcculls 74d714c1e7 Issue 552: (step 1) move core code to its own subdirectory
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1300 d779f126-a31b-0410-b53b-1d3aecad763e
2010-10-21 19:10:16 +00:00