Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished implementation of the invoke dynamic instrumentation.
- Loading branch information
Rafael Winterhalter
committed
Feb 16, 2015
1 parent
37febf6
commit ef37fe7
Showing
6 changed files
with
619 additions
and
152 deletions.
There are no files selected for viewing
592 changes: 444 additions & 148 deletions
592
byte-buddy-dep/src/main/java/net/bytebuddy/instrumentation/InvokeDynamic.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...et/bytebuddy/instrumentation/method/bytecode/stack/assign/AssignerEqualTypesOnlyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package net.bytebuddy.instrumentation.method.bytecode.stack.assign; | ||
|
||
import net.bytebuddy.instrumentation.Instrumentation; | ||
import net.bytebuddy.instrumentation.method.bytecode.stack.StackManipulation; | ||
import net.bytebuddy.instrumentation.type.TypeDescription; | ||
import net.bytebuddy.test.utility.MockitoRule; | ||
import org.junit.After; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestRule; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.mockito.Mock; | ||
import org.objectweb.asm.MethodVisitor; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.verifyZeroInteractions; | ||
|
||
@RunWith(Parameterized.class) | ||
public class AssignerEqualTypesOnlyTest { | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[] {false}, new Object[] {true}); | ||
} | ||
|
||
private final boolean dynamicallyTyped; | ||
|
||
public AssignerEqualTypesOnlyTest(boolean dynamicallyTyped) { | ||
this.dynamicallyTyped = dynamicallyTyped; | ||
} | ||
|
||
@Rule | ||
public TestRule mockitoRule = new MockitoRule(this); | ||
|
||
@Mock | ||
private TypeDescription first, second; | ||
|
||
@Mock | ||
private MethodVisitor methodVisitor; | ||
|
||
@Mock | ||
private Instrumentation.Context instrumentationContext; | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
verifyZeroInteractions(methodVisitor); | ||
verifyZeroInteractions(instrumentationContext); | ||
} | ||
|
||
@Test | ||
public void testAssignmentEqual() throws Exception { | ||
StackManipulation stackManipulation = Assigner.EqualTypesOnly.INSTANCE.assign(first, first, dynamicallyTyped); | ||
assertThat(stackManipulation.isValid(), is(true)); | ||
StackManipulation.Size size = stackManipulation.apply(methodVisitor, instrumentationContext); | ||
assertThat(size.getSizeImpact(), is(0)); | ||
assertThat(size.getMaximalSize(), is(0)); | ||
} | ||
|
||
@Test | ||
public void testAssignmentNotEqual() throws Exception { | ||
StackManipulation stackManipulation = Assigner.EqualTypesOnly.INSTANCE.assign(first, second, dynamicallyTyped); | ||
assertThat(stackManipulation.isValid(), is(false)); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...java/net/bytebuddy/instrumentation/method/bytecode/stack/assign/AssignerRefusingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package net.bytebuddy.instrumentation.method.bytecode.stack.assign; | ||
|
||
import net.bytebuddy.instrumentation.Instrumentation; | ||
import net.bytebuddy.instrumentation.method.bytecode.stack.StackManipulation; | ||
import net.bytebuddy.instrumentation.type.TypeDescription; | ||
import net.bytebuddy.test.utility.MockitoRule; | ||
import org.junit.After; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestRule; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.mockito.Mock; | ||
import org.objectweb.asm.MethodVisitor; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.verifyZeroInteractions; | ||
|
||
@RunWith(Parameterized.class) | ||
public class AssignerRefusingTest { | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[]{false}, new Object[]{true}); | ||
} | ||
|
||
private final boolean dynamicallyTyped; | ||
|
||
public AssignerRefusingTest(boolean dynamicallyTyped) { | ||
this.dynamicallyTyped = dynamicallyTyped; | ||
} | ||
|
||
@Rule | ||
public TestRule mockitoRule = new MockitoRule(this); | ||
|
||
@Mock | ||
private TypeDescription first, second; | ||
|
||
@Mock | ||
private MethodVisitor methodVisitor; | ||
|
||
@Mock | ||
private Instrumentation.Context instrumentationContext; | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
verifyZeroInteractions(methodVisitor); | ||
verifyZeroInteractions(instrumentationContext); | ||
} | ||
|
||
@Test | ||
public void testAssignmentEqual() throws Exception { | ||
StackManipulation stackManipulation = Assigner.Refusing.INSTANCE.assign(first, first, dynamicallyTyped); | ||
assertThat(stackManipulation.isValid(), is(false)); | ||
} | ||
|
||
@Test | ||
public void testAssignmentNotEqual() throws Exception { | ||
StackManipulation stackManipulation = Assigner.Refusing.INSTANCE.assign(first, second, dynamicallyTyped); | ||
assertThat(stackManipulation.isValid(), is(false)); | ||
} | ||
} |