Exemple #1
0
  private void restoreAndRemoveTransformedClasses(
      @Nonnull Set<ClassIdentification> classesToRestore) {
    RedefinitionEngine redefinitionEngine = new RedefinitionEngine();

    for (ClassIdentification transformedClassId : classesToRestore) {
      byte[] definitionToRestore = transformedClasses.get(transformedClassId);
      redefinitionEngine.restoreToDefinition(
          transformedClassId.getLoadedClass(), definitionToRestore);
    }

    transformedClasses.keySet().removeAll(classesToRestore);
  }
Exemple #2
0
  void removeMockedClasses(@Nonnull List<Class<?>> previousMockedClasses) {
    int currentMockedClassCount = mockedClasses.size();

    if (currentMockedClassCount > 0) {
      int previousMockedClassCount = previousMockedClasses.size();

      if (previousMockedClassCount == 0) {
        mockedClasses.clear();
        mockedTypesAndInstances.clear();
      } else if (previousMockedClassCount < currentMockedClassCount) {
        mockedClasses.retainAll(previousMockedClasses);
        mockedTypesAndInstances.keySet().retainAll(previousMockedClasses);
      }
    }
  }
Exemple #3
0
  void restoreTransformedClasses(@Nonnull Set<ClassIdentification> previousTransformedClasses) {
    if (!transformedClasses.isEmpty()) {
      Set<ClassIdentification> classesToRestore;

      if (previousTransformedClasses.isEmpty()) {
        classesToRestore = transformedClasses.keySet();
      } else {
        classesToRestore = getTransformedClasses();
        classesToRestore.removeAll(previousTransformedClasses);
      }

      if (!classesToRestore.isEmpty()) {
        restoreAndRemoveTransformedClasses(classesToRestore);
      }
    }
  }
Exemple #4
0
 @Nonnull
 Set<ClassIdentification> getTransformedClasses() {
   return transformedClasses.isEmpty()
       ? Collections.<ClassIdentification>emptySet()
       : new HashSet<ClassIdentification>(transformedClasses.keySet());
 }