Package java.lang.instrument

Examples of java.lang.instrument.ClassDefinition


     * @tests java.lang.instrument.ClassDefinition#getDefinitionClassFile()
     */
    public void test_getDefinitionClassFile() {
        byte[] emptyByteArray = new byte[0];
        byte[] someByteArray = new byte[1024];
        ClassDefinition cd = new ClassDefinition(this.getClass(),emptyByteArray);
        assertSame(emptyByteArray,cd.getDefinitionClassFile());       
        cd = new ClassDefinition(this.getClass(),someByteArray);
        assertSame(someByteArray,cd.getDefinitionClassFile());       
    }
View Full Code Here


                applicationClass.enhance();
                if (sigChecksum != applicationClass.sigChecksum) {
                    dirtySig = true;
                }
                BytecodeCache.cacheBytecode(applicationClass.enhancedByteCode, applicationClass.name, applicationClass.javaSource);
                newDefinitions.add(new ClassDefinition(applicationClass.javaClass, applicationClass.enhancedByteCode));
                currentState = new ApplicationClassloaderState();//show others that we have changed..
            }
        }
        if (newDefinitions.size() > 0) {
            Cache.clear();
View Full Code Here

    * @param clazz the clazz to be redefined.
    * @param classCode the new byte code implementation of <code>clazz</code>.
    */
   public synchronized void registerChange(Class<?> clazz, byte[] classCode)
   {
      ClassDefinition classDef = new ClassDefinition(clazz, classCode);
      this.classDefinitions.add(classDef);
   }
View Full Code Here

                applicationClass.enhance();
                if (sigChecksum != applicationClass.sigChecksum) {
                    dirtySig = true;
                }
                BytecodeCache.cacheBytecode(applicationClass.enhancedByteCode, applicationClass.name, applicationClass.javaSource);
                newDefinitions.add(new ClassDefinition(applicationClass.javaClass, applicationClass.enhancedByteCode));
                currentState = new ApplicationClassloaderState();//show others that we have changed..
            }
        }
        if (newDefinitions.size() > 0) {
            Cache.clear();
View Full Code Here

      return new ClassDefinition[] {};
    }
    List<ClassDefinition> classDefinitions = new ArrayList<ClassDefinition>();
    for (Class clazz : forbids) {
      byte[] transformers = getForbidBytesByClass(clazz);
      ClassDefinition classDefinition = new ClassDefinition(clazz, transformers);

      classDefinitions.add(classDefinition);
    }

    return classDefinitions.toArray(new ClassDefinition[0]);
View Full Code Here

            ClassDefinition[] definitions = new ClassDefinition[reloadMap.size()];
            String[] classNames = new String[reloadMap.size()];
            int i = 0;
            for (Map.Entry<Class<?>, byte[]> entry : reloadMap.entrySet()) {
                classNames[i] = entry.getKey().getName();
                definitions[i++] = new ClassDefinition(entry.getKey(), entry.getValue());
            }
            try {
                LOGGER.reload("Reloading classes {} (autoHotswap)", Arrays.toString(classNames));
                instrumentation.redefineClasses(definitions);
                LOGGER.debug("... reloaded classes {} (autoHotswap)", Arrays.toString(classNames));
View Full Code Here

                applicationClass.enhance();
                if (sigChecksum != applicationClass.sigChecksum) {
                    dirtySig = true;
                }
                BytecodeCache.cacheBytecode(applicationClass.enhancedByteCode, applicationClass.name, applicationClass.javaSource);
                newDefinitions.add(new ClassDefinition(applicationClass.javaClass, applicationClass.enhancedByteCode));
                currentState = new ApplicationClassloaderState();//show others that we have changed..
            }
        }
        if (newDefinitions.size() > 0) {
            Cache.clear();
View Full Code Here

                int sigChecksum = tc.sigChecksum;
                tc.enhance();
                if (sigChecksum != tc.sigChecksum) {
                    dirtySig = true;
                }
                newDefinitions.add(new ClassDefinition(tc.javaClass, tc.enhancedByteCode));
                currentState = new TemplateClassloaderState();//show others that we have changed..
            }
        }
        if (newDefinitions.size() > 0) {
            throw new ClassReloadException("Need Reload");
View Full Code Here

            ChangeSet.Element changeSetElement = (ChangeSet.Element) it.next();

            final byte[] bytecode = JoinPointFactory.redefineJoinPoint(changeSetElement.getCompilationInfo());

            changes[index] = new ClassDefinition(changeSetElement.getJoinPointInfo().getJoinPointClass(), bytecode);

        }

        try {
View Full Code Here

            throw new Exception("RedefineAgent Test error: class " + targetName + " not loaded.");
        }
        if (classfilebytes == null) {
            throw new Exception("RedefineAgent Error(6439234): no transform call for class " + targetName);
        }
        ClassDefinition cd = new ClassDefinition(targetClass, classfilebytes);
        inst.redefineClasses(cd);
        System.out.println("RedefineAgent did redefine.");
        if (gotRedefineTransform) {
            System.out.println("RedefineAgent got redefine transform.");
        } else {
View Full Code Here

TOP

Related Classes of java.lang.instrument.ClassDefinition

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.