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

Prototype CGLIB replacement (Issue 1133) #1298

Closed
Closed
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
6612a19
Use a weak cache to track circular proxy types.
mcculls Oct 5, 2019
6fb250b
No need to use bridge classloader for native JDK proxies involving a …
mcculls Oct 10, 2019
b916ace
Remove CGLIB dependency from the build
mcculls Oct 10, 2019
c894d61
Remove CGLIB related code and trim BytecodeGen back to the basics
mcculls Oct 10, 2019
91a7ad4
Immutable space-efficient trie that provides a fast index for
mcculls Oct 10, 2019
d7f8a91
Continue to flesh out BytecodeGen replacement
mcculls Oct 15, 2019
e9d9f59
Extract Visibility from old BytecodeGen
mcculls Oct 15, 2019
c5b5ebe
Basic class definers
mcculls Oct 15, 2019
9dbe269
Skeleton bytecode generators
mcculls Oct 15, 2019
d1e9767
Support additional detail about enhancer targets
mcculls Nov 25, 2019
aee104e
Determine enhanceable methods
mcculls Nov 25, 2019
d202312
Minor cleanup
mcculls Dec 6, 2019
f126ecd
More cleanup
mcculls Dec 9, 2019
a6b0ad5
Restore custom class-loading flag for compatibility
mcculls Dec 10, 2019
c0521c9
Move Visibility back to BytecodeGen
mcculls Dec 10, 2019
5b51cc2
Update test
mcculls Dec 14, 2019
6cfd827
Update javadoc
mcculls Dec 14, 2019
d47de13
Warn when intercepting package-private methods using CHILD class-loading
mcculls Dec 14, 2019
a957f05
Skip enhancing methods if they aren't visible using CHILD class loading
mcculls Dec 14, 2019
18ea2d6
Cleanup class definers
mcculls Dec 14, 2019
8f276c8
Cleanup method resolution
mcculls Dec 15, 2019
877c033
Cleanup method resolution
mcculls Dec 16, 2019
0a430a6
Commentary
mcculls Dec 16, 2019
03ffd81
Track original bridge methods
mcculls Dec 16, 2019
d0c9c6c
Bind preferred ClassDefiner
mcculls Dec 26, 2019
e39c316
Report minimum visibility supported by class definer
mcculls Dec 26, 2019
150911e
Add ClassDefining entry-point
mcculls Dec 27, 2019
a177a40
Add MethodResolving entry-point
mcculls Dec 27, 2019
c6210dd
Naming consistency
mcculls Dec 28, 2019
f7d1e38
Share enhancer glue according to which methods were enhanced
mcculls Dec 29, 2019
1503a32
Refactor how enhancers are built
mcculls Jan 5, 2020
f98d318
Refactor how methods are selected for enhancement/fast-classing
mcculls Feb 15, 2020
404d3cb
Cache enhancers for re-use plus other fixes/improvements
mcculls Feb 15, 2020
e79c5cf
Update ImmutableStringTrie to mimic generated class layout
mcculls Feb 19, 2020
89c5b56
Revert "Update ImmutableStringTrie to mimic generated class layout" -…
mcculls Feb 20, 2020
c6089c5
Flatten trie hierarchy
mcculls Feb 21, 2020
6981661
Refactor trie
mcculls Feb 21, 2020
0c95e02
Build trie from string array
mcculls Feb 21, 2020
ef7d60a
Use ClassValue to store enhancer/fast-class glue
mcculls Feb 21, 2020
8bdda4f
Collect constructors and methods for glueing in a single map
mcculls Feb 21, 2020
4f82906
'ByGuice' marker strings
mcculls Feb 24, 2020
125fb3c
Method naming
mcculls Feb 24, 2020
dec19ee
Common glue
mcculls Feb 24, 2020
f2e67e4
More common glue
mcculls Feb 26, 2020
67d6055
Boxing/unboxing
mcculls Feb 27, 2020
39f4139
Performance tweaks
mcculls Feb 29, 2020
3a6b35e
Collect intermediate enhancer builders while still keeping generated …
mcculls Feb 29, 2020
2b9b9ee
Simplification: use BiFunction as the base for all bytecode-generated…
mcculls Mar 3, 2020
0a7de4a
Use semicolon as separator in class-building signatures (guaranteed n…
mcculls Mar 3, 2020
c5db50f
Glue exception
mcculls Mar 3, 2020
22a1940
Refactor glue lambda approach
mcculls Mar 3, 2020
338fa26
Workaround https://github.com/mojohaus/animal-sniffer/issues/18
mcculls Mar 3, 2020
5446e2d
Skeleton enhancer and fast-class generators
mcculls Mar 4, 2020
9bf7307
Add convenience constructor that takes a collection of strings
mcculls Mar 6, 2020
98ad246
Simplify glue framework
mcculls Mar 7, 2020
c279289
Update constructor
mcculls Mar 7, 2020
c63c326
Minor performance tweak
mcculls Mar 7, 2020
e3fe387
Refactor fast-class to match updated glue approach
mcculls Mar 7, 2020
6a889ae
Refactor enhancer to match updated glue approach
mcculls Mar 8, 2020
54be06c
Only modify package-name for enhanced java.* types when we don't have…
mcculls Mar 8, 2020
0d95755
Use Arrays.setAll to shorten utility methods
mcculls Mar 8, 2020
b0e5aa6
FastClass progress
mcculls Mar 9, 2020
da7cd43
Rename parameter to match other methods
mcculls Mar 11, 2020
1189618
Extract common bytecode tasks into their own utility class
mcculls Mar 11, 2020
6b6c29f
Format
mcculls Mar 11, 2020
5983e53
Simplify stack pruning
mcculls Mar 11, 2020
f335751
Don't intercept Object.finalize()
mcculls Mar 11, 2020
85cd874
Enhancer progress
mcculls Mar 11, 2020
bfbe367
Collect enhanceable method candidates in same order as we'll use in the
mcculls Mar 12, 2020
8c757ce
ASM 7.3.1
mcculls Mar 12, 2020
3e2d2d4
Update expectation: proxy class remains as long as host class is around.
mcculls Mar 12, 2020
e372d14
Mimic standard reflection InvocationTargetException behaviour
mcculls Mar 12, 2020
424575c
Mimic CGLIB behaviour when attempting to enhance a final class
mcculls Mar 12, 2020
20f12a5
Optimization: each fast-class only handles methods declared by the host
mcculls Mar 12, 2020
cb6fb96
Store immutable bridge delegate map
mcculls Mar 12, 2020
046bec3
Only report matching superclass method instead of bridge when it's no…
mcculls Mar 12, 2020
66cdf62
Replace superclass delegation to bridge targets with virtual dispatch
mcculls Mar 12, 2020
59136c2
Defer final class check until we know we want to enhance it
mcculls Mar 12, 2020
904fc8b
Cast bridge arguments (if necessary) before invoking target
mcculls Mar 13, 2020
4dfc507
Match behaviour: non-visible constructor should throw IllegalArgument…
mcculls Apr 11, 2020
429a7fd
Allow enhanced classes to be extended/mocked/etc.
mcculls Apr 11, 2020
91dfea7
Match behaviour: only wrap enhancer creation errors inside ErrorExcep…
mcculls Apr 11, 2020
90d430b
Re-use local value
mcculls Apr 11, 2020
98f5e99
Move child loader creation to its own method
mcculls Apr 11, 2020
1d3abe4
Add option to prefer Unsafe.defineAnonymousClass over defineClass
mcculls Apr 13, 2020
3484d75
Support extending/mocking of any types defined by UnsafeClassDefiner
mcculls Apr 13, 2020
e5d4601
Match behaviour: only report non-bridge super-methods as enhanceable …
mcculls Apr 14, 2020
8beec58
Match behaviour: copy method modifiers when enhancing (except native/…
mcculls Apr 15, 2020
055c4fc
Bump ASM to 8.0.1
mcculls Apr 15, 2020
b735851
Cast to host when proxy is loaded anonymously, otherwise cast to proxy
mcculls Apr 16, 2020
3a2c4d1
Match behaviour: rework visiting of interface methods to match recurs…
mcculls Apr 19, 2020
6f8dd8f
If resolved method is final then don't report it as enhanceable.
mcculls Apr 22, 2020
fd2c82a
Mark FastClass/Enhancer source as generated
mcculls Apr 23, 2020
3362a6d
Match behaviour: wrap invocation errors in InvocationTargetException
mcculls Apr 23, 2020
4ea73c2
Optimization: use constant trie if only one key
mcculls Apr 23, 2020
5acc5b3
Improve scanning of interface methods to handle when a later declared…
mcculls Apr 23, 2020
20d38e8
Extend interception test to cover new interface merging
mcculls Apr 23, 2020
71f0658
Enable lambda optimization when we know the proxy is not anonymous, p…
mcculls Apr 23, 2020
8040fc6
javadoc
mcculls Apr 23, 2020
4cdd15d
Restore support for using 'mvn test' on the command-line
mcculls May 6, 2020
92e81c7
javadoc fixes from @markmarch
mcculls May 7, 2020
d7c51fd
missing colon
mcculls May 7, 2020
98c8935
visibility and other minor fixes from @markmarch
mcculls May 7, 2020
6536035
javadoc
mcculls May 8, 2020
30d770d
Update test to make expectations clearer
mcculls May 8, 2020
99bcb47
Document why the InvocationHandler method argument is left as null
mcculls May 8, 2020
c064987
clarify unsafe modes
mcculls May 8, 2020
acacc73
Remove stray null constant from generated invoker
mcculls May 8, 2020
aca4480
javadoc
mcculls May 10, 2020
24c0ce4
method and target will have same name, but use target.getName() for c…
mcculls May 10, 2020
e193fc2
Document pros/cons of the different guice_custom_class_loading options
mcculls May 11, 2020
d0f6176
Remove unnecessary logic (intercepted setter already uses original fa…
mcculls May 11, 2020
ef33fad
Document which methods can be enhanced
mcculls May 11, 2020
f1129c3
Add pseudo-Java structures for the different glue classes
mcculls May 12, 2020
5e5a2c0
Add run of core tests with ANONYMOUS class-loading
mcculls May 12, 2020
fcbaadd
Add run of core tests with CHILD class-loading
mcculls May 13, 2020
f191a0e
Exclude tests that rely on package access from being run with CHILD c…
mcculls May 13, 2020
ebfb5f0
Small visibility changes to allow these tests to be run with CHILD cl…
mcculls May 13, 2020
215c153
Fix canFastInvoke when using CHILD class-loading to check the class a…
mcculls May 13, 2020
852942d
javadoc
mcculls Jun 5, 2020
6f29cde
javadoc
mcculls Jun 6, 2020
1386c48
Clarify we're wrapping exceptions with InvocationTargetException to m…
mcculls Jun 6, 2020
774b89b
Explain we only need to target Java8 for the generated helpers
mcculls Jun 6, 2020
f396f7e
Improve FastClass performance: store adapted constructor handle in st…
mcculls Jun 8, 2020
d8ba81b
Merge remote-tracking branch 'upstream/master' into issue-1133-protot…
mcculls Jun 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ javadoc.packagenames=com.google.inject,com.google.inject.spi,\
com.google.inject.testing.fieldbinder
test.class=com.google.inject.AllTests
module=com.google.inject
imports=!net.sf.cglib.*,!org.objectweb.asm.*
imports=!org.objectweb.asm.*
46 changes: 29 additions & 17 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,13 @@
<artifactId>guava</artifactId>
</dependency>
<!--
| CGLIB is embedded by default by the JarJar build profile
| ASM is embedded by default by the JarJar build profile
-->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<optional>true</optional>
</dependency>
<!--
| Test dependencies
-->
Expand Down Expand Up @@ -106,6 +101,31 @@
<exclude>**/TypeConversionTest*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>anonymous-class-loading</id>
<phase>test</phase>
<goals><goal>test</goal></goals>
<configuration>
<argLine>-Dguice_custom_class_loading=ANONYMOUS</argLine>
</configuration>
</execution>
<execution>
<id>child-class-loading</id>
<phase>test</phase>
<goals><goal>test</goal></goals>
<configuration>
<argLine>-Dguice_custom_class_loading=CHILD</argLine>
<!--
| These tests rely on package access which CHILD loading doesn't have
-->
<excludes combine.children="append">
<exclude>**/BytecodeGenTest*</exclude>
<exclude>**/ProviderMethodsTest*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<!--
| Add OSGi manifest
Expand All @@ -116,7 +136,7 @@
<configuration>
<instructions>
<Bundle-Name>${project.artifactId}$(if;$(classes;NAMED;*.MethodAspect);; (no_aop))</Bundle-Name>
<Import-Package>!net.sf.cglib.*,!org.objectweb.asm.*,!com.google.inject.*,*</Import-Package>
<Import-Package>!org.objectweb.asm.*,!com.google.inject.*,*</Import-Package>
<Eclipse-ExtensibleAPI>true</Eclipse-ExtensibleAPI>
</instructions>
</configuration>
Expand Down Expand Up @@ -180,6 +200,7 @@
<configuration>
<symbols>NO_AOP</symbols>
<excludes>
**/aop/*.java,
**/InterceptorBinding.java,
**/InterceptorBindingProcessor.java,
**/InterceptorStackCallback.java,
Expand Down Expand Up @@ -222,7 +243,7 @@
</profile>
<profile>
<!--
| JarJar build profile: Embed CGLIB (and ASM) classes under a Guice namespace
| JarJar build profile: Embed ASM classes under a Guice namespace
-->
<id>guice.with.jarjar</id>
<activation>
Expand All @@ -247,17 +268,8 @@
<overwrite>true</overwrite>
<includes>
<include>*:asm*</include>
<include>*:cglib</include>
</includes>
<rules>
<rule>
<pattern>net.sf.cglib.*</pattern>
<result>com.google.inject.internal.cglib.$@1</result>
</rule>
<rule>
<pattern>net.sf.cglib.**.*</pattern>
<result>com.google.inject.internal.cglib.@1.$@2</result>
</rule>
<rule>
<pattern>org.objectweb.asm.*</pattern>
<result>com.google.inject.internal.asm.$@1</result>
Expand Down
4 changes: 2 additions & 2 deletions core/src/com/google/inject/Scopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.inject;

import com.google.inject.internal.CircularDependencyProxy;
import com.google.inject.internal.BytecodeGen;
import com.google.inject.internal.LinkedBindingImpl;
import com.google.inject.internal.SingletonScope;
import com.google.inject.spi.BindingScopingVisitor;
Expand Down Expand Up @@ -189,6 +189,6 @@ public Boolean visitEagerSingleton() {
* @since 4.0
*/
public static boolean isCircularProxy(Object object) {
return object instanceof CircularDependencyProxy;
return BytecodeGen.isCircularProxy(object);
}
}
Loading