Package java.lang.instrument

Examples of java.lang.instrument.ClassFileTransformer


    injectorOptions.setCriteria(methodCriteria);

    LOG.info("criteria = " + methodCriteria);
    try {
      ClassFileTransformer transformer;
      transformer = new InjectClassFileTransformer(injectorOptions);
      transformer = new FilterClassFileTransformer(methodCriteria, transformer);
      instrumentation.addTransformer(transformer);
      LOG.info("Installed " + transformer + ".");
      installed = true;
View Full Code Here


        // resolve against the system loader and injection into bootstrap classes fails. But that's still ok
        // because the byteman classes are still only foudn in one place.

        boolean isRedefine = inst.isRedefineClassesSupported();

        ClassFileTransformer transformer;
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        Class transformerClazz;

        if (allowRedefine && isRedefine) {
            transformerClazz = loader.loadClass("org.jboss.byteman.agent.Retransformer");
View Full Code Here

    private static Object newInstrumentedInstance(Class<?> cls) throws Exception {
        return instrumentClass(cls).newInstance();
    }

    private static Class<?> instrumentClass(Class<?> cls) throws Exception {
        ClassFileTransformer transformer = new ThreadSafetyCheckerTransformer() {
            @Override
            protected ClassVisitor getAdapters(ClassVisitor cv) {
                return super.getAdapters(new CheckClassAdapter(cv));
            }
        };
View Full Code Here

    transformers.addAll( createConvenienceTransformers() );

    //Add the configured class transformers
    if ( classTransformers != null ) {
      for (final String className : classTransformers) {
        final ClassFileTransformer instance = createAgentInstance(className);
        transformers.add( instance );
      }
    }
    return transformers;
  }
View Full Code Here

        }

        ProtectionDomain protectionDomain = null;

        for (int i = 0; i < _classFileTransformerList.size(); i++) {
          ClassFileTransformer transformer = _classFileTransformerList.get(i);

          try {
            byte []enhancedBuffer = transformer.transform(this,
                                                          className,
                                                          redefineClass,
                                                          protectionDomain,
                                                          bBuf);
View Full Code Here

            modelFound = finderClass.getDeclaredMethod("modelFound", String.class);
        } catch (Exception e) {
            throw new InstrumentationException(e);
        }

        inst.addTransformer(new ClassFileTransformer() {
            @Override
            public synchronized byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
                                                 ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
                try {
View Full Code Here

  @Nonnull
  private Collection<ClassFileTransformer> getAgents() throws MojoExecutionException {
    final Collection<ClassFileTransformer> agents = new ArrayList<ClassFileTransformer>();
    for (final String className : classTransformers) {
      final ClassFileTransformer instance = createAgentInstance(className);
      agents.add(instance);
    }
    return agents;
  }
View Full Code Here

    }

    static void install(String agentArgs, Instrumentation inst) {
        logger.info("[MtContextAgent.install] agentArgs: " + agentArgs + ", Instrumentation: " + inst);

        ClassFileTransformer transformer = new MtContextTransformer();
        inst.addTransformer(transformer, true);

        logger.info("[MtContextAgent.install] addTransformer success.");
    }
View Full Code Here

        }

        ProtectionDomain protectionDomain = null;

        for (int i = 0; i < _classFileTransformerList.size(); i++) {
          ClassFileTransformer transformer = _classFileTransformerList.get(i);

          try {
            byte []enhancedBuffer = transformer.transform(this,
                                                          className,
                                                          redefineClass,
                                                          protectionDomain,
                                                          bBuf);
View Full Code Here

TOP

Related Classes of java.lang.instrument.ClassFileTransformer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.