Skip to content

Commit

Permalink
[ci maven-central-release] Merge pull request #2046 from mockito/incl…
Browse files Browse the repository at this point in the history
…ude-synthetic

Do not exclude synthetic constructors from instrumentation. Fixes #2040.
  • Loading branch information
raphw authored Sep 17, 2020
2 parents b6ae6cf + 4a40f58 commit ce996dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public InlineBytecodeGenerator(
new ByteBuddy()
.with(TypeValidation.DISABLED)
.with(Implementation.Context.Disabled.Factory.INSTANCE)
.with(MethodGraph.Compiler.ForDeclaredMethods.INSTANCE);
.with(MethodGraph.Compiler.ForDeclaredMethods.INSTANCE)
.ignore(isSynthetic().and(not(isConstructor())).or(isDefaultFinalizer()));
mocked = new WeakConcurrentSet<>(WeakConcurrentSet.Cleaner.INLINE);
flatMocked = new WeakConcurrentSet<>(WeakConcurrentSet.Cleaner.INLINE);
String identifier = RandomString.make();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,14 @@ public MethodVisitor wrap(
.getDeclaredMethods()
.filter(isConstructor().and(not(isPrivate())));
int arguments = Integer.MAX_VALUE;
boolean visible = false;
boolean packagePrivate = true;
MethodDescription.InDefinedShape current = null;
for (MethodDescription.InDefinedShape constructor : constructors) {
if (constructor.getParameters().size() < arguments
&& (!visible || constructor.isPackagePrivate())) {
&& (packagePrivate || !constructor.isPackagePrivate())) {
arguments = constructor.getParameters().size();
packagePrivate = constructor.isPackagePrivate();
current = constructor;
visible = constructor.isPackagePrivate();
}
}
if (current != null) {
Expand Down

0 comments on commit ce996dc

Please sign in to comment.