Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests
PiperOrigin-RevId: 337602195
Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests
PiperOrigin-RevId: 337401912
The goal is to move the cost of tracking these data structures out of the fast path on the assumption that provisioning rarely fails and so the cost of calling Errors.withSource (and Errors.size()/Errors.throwIfNewErrors()....) is mostly wasted. Instead we can add catch blocks that do this work.
This has 2 immediate consequences:
1. since the provisioning stack is calculated as exceptions propagate it will be incomplete if the exception is caught 'early'. For example, previously if a ProvisionListener caught a ProvisionException, the exception would show, via the chain of sources, the full path to the failed provision. Now it will only show the path 'below' where it was caught. updated tests in ProvisionListenerTest demonstrate this
2. A number of places where multiple errors used to be collected now no longer do (for example, the first member injector to throw will short circuit other members injectors). This is an extension of a prior CL which removed multiple error collection from SingleParameterInjector.
This builds on the InternalProvisionException introduced in an earlier patch. The change is fairly mechanical, but since this changes the calling convention for Guice, all points which participate need to be updated together. In particular,
* the signature of InternalFactory.get(...) was changed by removing the Errors object and changing the 'throws' signature.
* All Errors.withSource(...) calls were changed to InternalProvisionException.addSource calls in a catch block.
Benchmarks show that this drops provisioning time by about 20% and allocated objects by about the same (no more Errors objects!).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178414361
We will still collect multiple errors during configuration, but during
provisioning there are fewer benefits and in highly connected binding graphs
this can result in an error being reported once for every path to a broken
binding. Even with this change multiple errors can be collected while injecting multiple members of a single object and in a few other less common ways (returning null from a non-nullable injection point). But this cl removes the most common way.
This is also an enabling change. With this it should be possible to move all
calls to Errors.withSource into catch blocks in the factory objects. So that
instead of recording progress as we provision, we will only record the sources
when the provision actually fails. This will save an allocation for every node
and edge in the binding graph. (this change will happen in a followup)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173327556
In 41f307e21b this AbstractModule.configure() became non-abstract in the base class, so it is now allowed for subclasses to not override the method at all when they don’t need to access the binding dsl.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148043119
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
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
Given the method
void foo(A a, B b) {}
Guice currently prints "parameter 1 of foo" to refer to 'b', but most people (based on an informal survey), believe it refers to 'a'. To resolve this confusion Guice will now print "the 2nd parameter of foo" to refer to 'b'.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=125128691
the same cause, don't list them individually and instead use as the Throwable's
cause. If some (but not all) errors are duplicates, elide the duplicate stack
traces and point to the error # it's the same as.
"same" here is defined as the same exception class, same stack trace, and same causes (with causes using the same 'same' definition).
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=92389485
I wrote an error-prone checker([]) to check that injected constructors are not annotated with @Inject(optional=true) or with binding annotations. This CL annotates the intentional tests for such cases with @SuppressWarnings.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64575706
By setting guice_include_stack_traces flag OFF, Guice does not collect stack traces for identifying the declaring source of a binding. Instead it uses the first non-skipped module class name from the modules stack. As a result, in some cases, error messages can be slightly different with this flag. For example, the file name and line number are not always available.
A sample error message with this flag :
Guice creation errors:
1) Received null converting foo (bound at com.google.inject.TypeConversionTest.configure(Unknown Source) (via modules: com.google.inject.TypeConversionTest -> com.google.inject.TypeConversionTest)) to java.util.Date
using CustomConverter which matches only(java.util.Date) (bound at com.google.inject.TypeConversionTest.configure(Unknown Source) (via modules: com.google.inject.TypeConversionTest -> com.google.inject.TypeConversionTest -> com.google.inject.TypeConversionTest)).
while locating java.util.Date annotated with @com.google.inject.TypeConversionTest()
for field at com.google.inject.TypeConversionTest.date(TypeConversionTest.java:478)
at com.google.inject.TypeConversionTest.configure(Unknown Source) (via modules: com.google.inject.TypeConversionTest -> com.google.inject.TypeConversionTest)
This also changes the DEFAULT flag name to ONLY_FOR_DECLARTION_SOURCE.
Adds InternalFlags.getIncludeStackTraceOption() to wrap system property access.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=53610378
* 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