@Test
 public void testInstrumentationModernClassFile() throws Exception {
   ClassVisitor classVisitor =
       TypeConstantAdjustment.INSTANCE.wrap(
           mock(TypeDescription.class),
           this.classVisitor,
           mock(Implementation.Context.class),
           mock(TypePool.class),
           new FieldList.Empty<FieldDescription.InDefinedShape>(),
           new MethodList.Empty<MethodDescription>(),
           IGNORED,
           IGNORED);
   classVisitor.visit(
       ClassFileVersion.JAVA_V5.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[] {BAZ});
   assertThat(
       classVisitor.visitMethod(FOOBAR, FOO, BAR, QUX, new String[] {BAZ}), is(methodVisitor));
   verify(this.classVisitor)
       .visit(
           ClassFileVersion.JAVA_V5.getMinorMajorVersion(),
           FOOBAR,
           FOO,
           BAR,
           QUX,
           new String[] {BAZ});
   verify(this.classVisitor).visitMethod(FOOBAR, FOO, BAR, QUX, new String[] {BAZ});
   verifyNoMoreInteractions(this.classVisitor);
   verifyZeroInteractions(methodVisitor);
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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));
 }