Exemplo n.º 1
0
 @Before
 public void setUp() throws Exception {
   explicitAuxiliaryTypes = Collections.singletonList(firstAuxiliary);
   when(engine.create(any(Instrumentation.Context.ExtractableView.class))).thenReturn(MAIN);
   when(firstAuxiliary.getTypeDescription()).thenReturn(otherAuxiliaryDescription);
   when(firstAuxiliary.getBytes()).thenReturn(FIRST);
 }
Exemplo n.º 2
0
 @Override
 public int hashCode() {
   int result = super.hashCode();
   result = 31 * result + placeholderType.hashCode();
   result = 31 * result + methodNameTransformer.hashCode();
   return result;
 }
Exemplo n.º 3
0
 @Override
 protected Resolution rebase(MethodDescription.InDefinedShape methodDescription) {
   return methodDescription.isConstructor()
       ? Resolution.ForRebasedConstructor.of(
           methodDescription, placeholderType.getTypeDescription())
       : Resolution.ForRebasedMethod.of(methodDescription, methodNameTransformer);
 }
Exemplo n.º 4
0
 @Override
 public boolean equals(Object other) {
   return this == other
       || !(other == null || getClass() != other.getClass())
           && super.equals(other)
           && placeholderType.equals(((Enabled) other).placeholderType)
           && methodNameTransformer.equals(((Enabled) other).methodNameTransformer);
 }
Exemplo n.º 5
0
 @Test
 public void testDynamicTypeCreation() throws Exception {
   DynamicType dynamicType =
       new TypeWriter.Default<Object>(
               instrumentedType,
               loadedTypeInitializer,
               typeInitializer,
               explicitAuxiliaryTypes,
               classFileVersion,
               engine)
           .make();
   assertThat(dynamicType.getBytes(), is(MAIN));
   assertThat(dynamicType.getTypeDescription(), is(instrumentedType));
   assertThat(
       dynamicType.getLoadedTypeInitializers().get(instrumentedType), is(loadedTypeInitializer));
   assertThat(dynamicType.getRawAuxiliaryTypes().size(), is(1));
   assertThat(dynamicType.getRawAuxiliaryTypes().get(otherAuxiliaryDescription), is(FIRST));
 }
Exemplo n.º 6
0
 @Test
 public void testPlain() throws Exception {
   when(classFileVersion.getMinorMajorVersion())
       .thenReturn(ClassFileVersion.JAVA_V5.getMinorMajorVersion());
   DynamicType dynamicType = TrivialType.PLAIN.make(FOO, classFileVersion, methodAccessorFactory);
   assertThat(dynamicType.getTypeDescription().getName(), is(FOO));
   assertThat(dynamicType.getTypeDescription().getModifiers(), is(Opcodes.ACC_SYNTHETIC));
   assertThat(dynamicType.getTypeDescription().getDeclaredAnnotations().size(), is(0));
   assertThat(dynamicType.getAuxiliaryTypes().size(), is(0));
   assertThat(
       dynamicType.getLoadedTypeInitializers().get(dynamicType.getTypeDescription()).isAlive(),
       is(false));
 }
Exemplo n.º 7
0
 @Test
 public void testEager() throws Exception {
   when(classFileVersion.getMinorMajorVersion())
       .thenReturn(ClassFileVersion.JAVA_V5.getMinorMajorVersion());
   DynamicType dynamicType =
       TrivialType.SIGNATURE_RELEVANT.make(FOO, classFileVersion, methodAccessorFactory);
   assertThat(dynamicType.getTypeDescription().getName(), is(FOO));
   assertThat(dynamicType.getTypeDescription().getModifiers(), is(Opcodes.ACC_SYNTHETIC));
   assertThat(dynamicType.getTypeDescription().getDeclaredAnnotations().size(), is(1));
   assertThat(
       dynamicType
           .getTypeDescription()
           .getDeclaredAnnotations()
           .isAnnotationPresent(AuxiliaryType.SignatureRelevant.class),
       is(true));
   assertThat(dynamicType.getAuxiliaryTypes().size(), is(0));
   assertThat(
       dynamicType.getLoadedTypeInitializers().get(dynamicType.getTypeDescription()).isAlive(),
       is(false));
 }