示例#1
0
  @Override
  @SuppressWarnings("CallToThreadDumpStack")
  public void visitEnd() {
    classEntry.setRequiresInstrumentation(false);
    db.recordSuspendableMethods(className, classEntry);

    if (methods != null && !methods.isEmpty()) {
      if (alreadyInstrumented && !forceInstrumentation) {
        for (MethodNode mn : methods) mn.accept(makeOutMV(mn));
      } else {
        if (!alreadyInstrumented) {
          super.visitAnnotation(ALREADY_INSTRUMENTED_NAME, true);
          classEntry.setInstrumented(true);
        }

        for (MethodNode mn : methods) {
          final MethodVisitor outMV = makeOutMV(mn);
          try {
            InstrumentMethod im = new InstrumentMethod(db, className, mn);
            if (db.isDebug())
              db.log(
                  LogLevel.INFO, "About to instrument method %s#%s%s", className, mn.name, mn.desc);

            if (im.collectCodeBlocks()) {
              if (mn.name.charAt(0) == '<')
                throw new UnableToInstrumentException(
                    "special method", className, mn.name, mn.desc);
              im.accept(outMV, hasAnnotation(mn));
            } else mn.accept(outMV);
          } catch (AnalyzerException ex) {
            ex.printStackTrace();
            throw new InternalError(ex.getMessage());
          }
        }
      }
    } else {
      // if we don't have any suspendable methods, but our superclass is instrumented, we mark this
      // class as instrumented, too.
      if (!alreadyInstrumented && classEntry.getSuperName() != null) {
        ClassEntry superClass = db.getClassEntry(classEntry.getSuperName());
        if (superClass != null && superClass.isInstrumented()) {
          super.visitAnnotation(ALREADY_INSTRUMENTED_NAME, true);
          classEntry.setInstrumented(true);
        }
      }
    }
    super.visitEnd();
  }
示例#2
0
 public MethodAnalysisResults analyzeLambda(
     String className, String methodName, String methodSignature) {
   try {
     // Open up the corresponding class to analyze
     QueryllPathAnalysisSupplementalFactory pathAnalysisFactory =
         new QueryllPathAnalysisSupplementalFactory(entityInfo, new ArrayList<>());
     TransformationClassAnalyzer classAnalyzer = new TransformationClassAnalyzer(className);
     MethodAnalysisResults analysis =
         classAnalyzer.analyzeLambdaMethod(methodName, methodSignature, pathAnalysisFactory);
     return analysis;
   } catch (IOException e) {
     e.printStackTrace();
     return null;
   } catch (AnalyzerException e) {
     e.printStackTrace();
     return null;
   }
 }