示例#1
0
  private ClassType defineClasses(
      Collection<OutputFileObject> classes,
      EvaluationContext context,
      DebugProcess process,
      ClassLoaderReference classLoader)
      throws EvaluateException, InvalidTypeException, ClassNotLoadedException {

    VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl) process.getVirtualMachineProxy();
    for (OutputFileObject cls : classes) {
      if (cls.getName().contains(GEN_CLASS_NAME)) {
        Method defineMethod =
            ((ClassType) classLoader.referenceType())
                .concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;");
        byte[] bytes = changeSuperToMagicAccessor(cls.toByteArray());
        ArrayList<Value> args = new ArrayList<Value>();
        StringReference name = proxy.mirrorOf(cls.myOrigName);
        keep(name, context);
        args.add(name);
        args.add(mirrorOf(bytes, context, process));
        args.add(proxy.mirrorOf(0));
        args.add(proxy.mirrorOf(bytes.length));
        process.invokeMethod(context, classLoader, defineMethod, args);
      }
    }
    return (ClassType) process.findClass(context, getGenClassQName(), classLoader);
  }