Package java.lang.instrument

Examples of java.lang.instrument.Instrumentation.redefineClasses()


                // in a Java 5 context, we can use class redefinition instead
                ClassDefinition[] defs = new ClassDefinition[array.length];
                for (int i = 0; i < defs.length; i++)
                    defs[i] = new ClassDefinition(array[i],
                        classes.get(array[i]));
                inst.redefineClasses(defs);
            }
        } catch (NoSuchMethodException e) {
            throw new InternalException(e);
        } catch (IllegalAccessException e) {
            throw new InternalException(e);
View Full Code Here


            return;
        }

        // try to reload them all
        try {
            instrumentation.redefineClasses(changes);
            for (int i=0; i<changes.length; i++) succeeded[i] = true;
        } catch (Exception e) {
            // throw new AWGenericException(e);
            if (changes.length == 1) {
                succeeded[0] = false;
View Full Code Here

            } else {
                // we failed to load one or more, so try to load them individually
                for (int i=0; i<changes.length; i++) {
                    ClassDefinition[] change = new ClassDefinition[] {changes[i]};
                    try {
                        instrumentation.redefineClasses(change);
                        succeeded[i] = true;
                    } catch (Exception e2) {
                        succeeded[i] = false;
                    }
                }
View Full Code Here

                // in a Java 5 context, we can use class redefinition instead
                ClassDefinition[] defs = new ClassDefinition[array.length];
                for (int i = 0; i < defs.length; i++)
                    defs[i] = new ClassDefinition(array[i],
                        classes.get(array[i]));
                inst.redefineClasses(defs);
            }
        } catch (NoSuchMethodException e) {
            throw new InternalException(e);
        } catch (IllegalAccessException e) {
            throw new InternalException(e);
View Full Code Here

                // in a Java 5 context, we can use class redefinition instead
                ClassDefinition[] defs = new ClassDefinition[array.length];
                for (int i = 0; i < defs.length; i++)
                    defs[i] = new ClassDefinition(array[i],
                        classes.get(array[i]));
                inst.redefineClasses(defs);
            }
        } catch (Exception e) {
            throw new InternalException(e);
        } finally {
            if (inst != null && t != null)
View Full Code Here

   */
  public static boolean redefineClassEL(Class clazz, byte[] barr){
    Instrumentation inst = InstrumentationFactory.getInstance();
      if(inst!=null && inst.isRedefineClassesSupported()) {
        try {
            inst.redefineClasses(new ClassDefinition(clazz,barr));
        return true;
      }
        catch (Throwable t) {t.printStackTrace();}
      }
      return false;
View Full Code Here

      return false;
  }

  public static void redefineClass(Class clazz, byte[] barr) throws ClassNotFoundException, UnmodifiableClassException{
    Instrumentation inst = InstrumentationFactory.getInstance();
      inst.redefineClasses(new ClassDefinition(clazz,barr));
  }

  public static boolean isSupported() {
    Instrumentation inst = InstrumentationFactory.getInstance();
    return (inst!=null && inst.isRedefineClassesSupported());
View Full Code Here

        ClassDefinition[] definitions = new ClassDefinition[classes.size()];
        int i = 0;
        for (Map.Entry<Class<?>, byte[]> entry : classes.entrySet()) {
            definitions[i++] = new ClassDefinition(entry.getKey(), entry.getValue());
        }
        instrumentation.redefineClasses(definitions);
    }

    @Override
    public void close() throws IOException {
        // Do nothing.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.